Dashboards & Visualizations

How do I hide a dropdown based on a checkbox value in a Splunk dashboard?

Explorer

I have 2 dropdowns in a panel and I want to show them based on the value of a checkbox defined in the same dashboard. Can someone please let me know the changes required in XML for the same?

Checkbox :

ValueA
ValueB

If we choose valueA - Dropdown1 should be displayed
if we choose valueB - Dropdown2 should be displayed

Thanks

0 Karma
1 Solution

Super Champion

Hi @AnmolKohli,
Try below :

<fieldset submitButton="false">
      <input type="checkbox" token="view">
        <label>View</label>
          <choice value="ValueA">ValueA</choice>
        <choice value="ValueB">ValueB</choice>
        <default>site</default>
        <change>
          <condition value="ValueA">
              <set token="A">true</set>
              <unset token="B"></unset>
            </condition>
            <condition value="ValueB">
              <set token="B">true</set>
              <unset token="A"></unset>
            </condition>
        </change>
      </input>
      <input type="dropdown" token="test" depends="$A$" >
        <label>dropdown 1</label>
        <choice value="data1">Data1</choice>
        <choice value="data2">Data2</choice>
      </input>
      <input type="dropdown" token="test2" depends="$B$" >
        <label>dropdown 2</label>
        <choice value="data3">Data3</choice>
        <choice value="data4">Data4</choice>
      </input>
    </fieldset>

Here as per checkbox value it will set and unset token and dropdown will be depends on these token to hide or show ...this is not yet tested but you will get an idea

View solution in original post

SplunkTrust
SplunkTrust

@AnmolKohli , if you need to select only on check box and accordingly only display one Dropdown the solution by @493669 should work. However, if this is actually your use case ideally you should be using Radio button instead of check box which will allow you to select only one option at a time.

With checkbox users will have option to choose both values A and B, which is when the above solution will not work. You would need to use independent search to set/unset the the required tokens based on multiple selections. Refer to following answer on Similar lines: https://answers.splunk.com/answers/681330/can-i-hideunhide-specific-text-boxes-using-a-singl.html

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"
0 Karma

Super Champion

Hi @AnmolKohli,
Try below :

<fieldset submitButton="false">
      <input type="checkbox" token="view">
        <label>View</label>
          <choice value="ValueA">ValueA</choice>
        <choice value="ValueB">ValueB</choice>
        <default>site</default>
        <change>
          <condition value="ValueA">
              <set token="A">true</set>
              <unset token="B"></unset>
            </condition>
            <condition value="ValueB">
              <set token="B">true</set>
              <unset token="A"></unset>
            </condition>
        </change>
      </input>
      <input type="dropdown" token="test" depends="$A$" >
        <label>dropdown 1</label>
        <choice value="data1">Data1</choice>
        <choice value="data2">Data2</choice>
      </input>
      <input type="dropdown" token="test2" depends="$B$" >
        <label>dropdown 2</label>
        <choice value="data3">Data3</choice>
        <choice value="data4">Data4</choice>
      </input>
    </fieldset>

Here as per checkbox value it will set and unset token and dropdown will be depends on these token to hide or show ...this is not yet tested but you will get an idea

View solution in original post

Explorer

Worked 🙂 Thanks

0 Karma

SplunkTrust
SplunkTrust

@AnmolKohli If your problem is resolved, please accept an answer to help future readers.

---
If this reply helps you, an upvote would be appreciated.
0 Karma