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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Persistent Queue at TcpOut — One of Splunk's Most Practical Features

Splunk introduced persistent queueing at the tcpout layer as one of the most practical resilience features in ...

Skip the Awkward Silence: Have a .conf-ersation at .conf26

Picture this. You arrive at .conf26 already having your socializing and networking plans mapped out. No ...

Rethinking Zero Trust: From Product Purchases to Logical Control Evidence

Implementing Zero Trust (ZT) across complex environments often falters at the very beginning due to a ...