Dashboards & Visualizations

Hide and Show Input Dropdown Based Upon Another Input Drop Down

handsomehari
Explorer

I have two different dropdowns and i want to hide and show second dropdown(category) based upon of first selectoin. Tried below way, but not working. If choice site is selected second dropdown (category) should be displayed else if choice container is selected second dropdown (category) should be in hidden.

 <fieldset submitButton="false">
    <input type="dropdown" token="view">
      <label>View</label>
        <choice value="site">Site</choice>
      <choice value="container">Container</choice>
      <default>site</default>
      <change>
        <condition match="$view$ == site">
            <set token="show_category">true</set>
          </condition>
          <condition match="$view$ != site">
            <unset token="show_category"></unset>
          </condition>
      </change>
    </input>
    <input type="dropdown" token="category" depends="$show_category$" >
      <label>Category</label>
      <choice value="data1">Data1</choice>
      <choice value="data2">Data2</choice>
    </input>
  </fieldset>
1 Solution

niketn
Legend

@handsomehari, please try the following instead. It shows second dropdown only when the first dropdown's selected value is site. For selected input's change event you can use value and label to access them directly in condition block.

  <fieldset submitButton="false">
     <input type="dropdown" token="view">
       <label>View</label>
         <choice value="site">Site</choice>
       <choice value="container">Container</choice>
       <default>site</default>
       <change>
         <condition value="site">
             <set token="show_category">true</set>
           </condition>
           <condition>
             <unset token="show_category"></unset>
           </condition>
       </change>
     </input>
     <input type="dropdown" token="category" depends="$show_category$" >
       <label>Category</label>
       <choice value="data1">Data1</choice>
       <choice value="data2">Data2</choice>
     </input>
   </fieldset>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

View solution in original post

sayanidasgupta
Explorer

this code is working brilliantly..

Please help me with this,
I have more values in 1st Dropdown ( e.g - except site and container) and depending on the values of 1st dropdown I have to open dropdown of that particular value -

  <label>Select Category</label>
  <choice value="capability">CAPABILITY</choice>
  <choice value="lob">LOB</choice>
  <choice value="service">SERVICE</choice>
  <choice value="client">CLIENT</choice>
  <change>
  <condition value="capability">
  <set token="show_capability">true</set>
  </condition>
  <condition>
  <unset token="show_capability"></unset>
  </condition>

  <condition value="lob">
  <set token="show_lobName">true</set>
  </condition>
  <condition>
  <unset token="show_lobName"></unset>
  </condition>
  </change>

This is my code... code works well with both the condition separately - means if I comment value=lob section capability dropdown is coming, if I comment capability, lob dropdown is coming,
but together both option is not working, when I am selecting capability, capability dropdown is coming but while selecting lob , lob dropdown is not coming and also I need to hide other dropdown when selecting new value from 1st dropdown.

Please help

0 Karma

niketn
Legend

@handsomehari, please try the following instead. It shows second dropdown only when the first dropdown's selected value is site. For selected input's change event you can use value and label to access them directly in condition block.

  <fieldset submitButton="false">
     <input type="dropdown" token="view">
       <label>View</label>
         <choice value="site">Site</choice>
       <choice value="container">Container</choice>
       <default>site</default>
       <change>
         <condition value="site">
             <set token="show_category">true</set>
           </condition>
           <condition>
             <unset token="show_category"></unset>
           </condition>
       </change>
     </input>
     <input type="dropdown" token="category" depends="$show_category$" >
       <label>Category</label>
       <choice value="data1">Data1</choice>
       <choice value="data2">Data2</choice>
     </input>
   </fieldset>
____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

lfedak_splunk
Splunk Employee
Splunk Employee

Hey @handsomehair, if this worked for you please remember to "accept" niketnilay's answer! 🙂 It'll award him karma points.

0 Karma

handsomehari
Explorer

Thanks... It worked...

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...