Splunk Search

How to display checkbox based on parent checkbox selection

paviach
New Member

I need to display list of checkboxes based on the parent check box selection.
Say, I have 1, 2, 3 as parent checkboxes and each will have list of its own checkboxes.
When 1 is checked, it should display the list of checkboxes intended for option 1.

Someone please help me out on this.

Tags (3)
0 Karma
1 Solution

jacobpevans
Motivator

Greetings @paviach,

It would look something like this run-anywhere dashboard. You need to use depends="$token$" to hide fields, rows, and/or panels.

<form>
  <fieldset submitButton="false">
    <input type="checkbox" token="tokParent" searchWhenChanged="true">
      <label>Parent Checkboxes</label>
      <choice value="parent1">Parent 1</choice>
      <choice value="parent2">Parent 2</choice>
      <choice value="parent3">Parent 3</choice>
      <change>
        <condition value="parent1">
          <set token="showParent1">true</set>
          <unset token="showParent2"></unset>
          <unset token="showParent3"></unset>
        </condition>
        <condition value="parent2">
          <set token="showParent2">true</set>
          <unset token="showParent1"></unset>
          <unset token="showParent3"></unset>
        </condition>
        <condition value="parent3">
          <set token="showParent3">true</set>
          <unset token="showParent1"></unset>
          <unset token="showParent2"></unset>
        </condition>
        <condition>
          <unset token="showParent1"></unset>
          <unset token="showParent2"></unset>
          <unset token="showParent3"></unset>
        </condition>
      </change>
    </input>
    <input type="checkbox" token="tokChild1_1" searchWhenChanged="true" depends="$showParent1$">
      <label>Child 1 of Parent 1</label>
      <choice value="child1_1_1">Parent 1 Child 1 Option 1</choice>
      <choice value="child1_1_2">Parent 1 Child 1 Option 2</choice>
    </input>
    <input type="checkbox" token="tokChild1_2" searchWhenChanged="true" depends="$showParent1$">
      <label>Child 1 of Parent 1</label>
      <choice value="child1_2_1">Parent 1 Child 2 Option 1</choice>
      <choice value="child1_2_2">Parent 1 Child 2 Option 2</choice>
    </input>

    <input type="checkbox" token="tokChild2_1" searchWhenChanged="true" depends="$showParent2$">
      <label>Child 1 of Parent 2</label>
      <choice value="child2_1_1">Parent 2 Child 1 Option 1</choice>
      <choice value="child2_1_2">Parent 2 Child 1 Option 2</choice>
    </input>

    <input type="checkbox" token="tokChild3_1" searchWhenChanged="true" depends="$showParent3$">
      <label>Child 1 of Parent 3</label>
      <choice value="child3_1_1">Parent 3 Child 1 Option 1</choice>
      <choice value="child3_1_2">Parent 3 Child 1 Option 2</choice>
    </input>
  </fieldset>
</form>
Cheers,
Jacob

If you feel this response answered your question, please do not forget to mark it as such. If it did not, but you do have the answer, feel free to answer your own post and accept that as the answer.

View solution in original post

0 Karma

jacobpevans
Motivator

Greetings @paviach,

It would look something like this run-anywhere dashboard. You need to use depends="$token$" to hide fields, rows, and/or panels.

<form>
  <fieldset submitButton="false">
    <input type="checkbox" token="tokParent" searchWhenChanged="true">
      <label>Parent Checkboxes</label>
      <choice value="parent1">Parent 1</choice>
      <choice value="parent2">Parent 2</choice>
      <choice value="parent3">Parent 3</choice>
      <change>
        <condition value="parent1">
          <set token="showParent1">true</set>
          <unset token="showParent2"></unset>
          <unset token="showParent3"></unset>
        </condition>
        <condition value="parent2">
          <set token="showParent2">true</set>
          <unset token="showParent1"></unset>
          <unset token="showParent3"></unset>
        </condition>
        <condition value="parent3">
          <set token="showParent3">true</set>
          <unset token="showParent1"></unset>
          <unset token="showParent2"></unset>
        </condition>
        <condition>
          <unset token="showParent1"></unset>
          <unset token="showParent2"></unset>
          <unset token="showParent3"></unset>
        </condition>
      </change>
    </input>
    <input type="checkbox" token="tokChild1_1" searchWhenChanged="true" depends="$showParent1$">
      <label>Child 1 of Parent 1</label>
      <choice value="child1_1_1">Parent 1 Child 1 Option 1</choice>
      <choice value="child1_1_2">Parent 1 Child 1 Option 2</choice>
    </input>
    <input type="checkbox" token="tokChild1_2" searchWhenChanged="true" depends="$showParent1$">
      <label>Child 1 of Parent 1</label>
      <choice value="child1_2_1">Parent 1 Child 2 Option 1</choice>
      <choice value="child1_2_2">Parent 1 Child 2 Option 2</choice>
    </input>

    <input type="checkbox" token="tokChild2_1" searchWhenChanged="true" depends="$showParent2$">
      <label>Child 1 of Parent 2</label>
      <choice value="child2_1_1">Parent 2 Child 1 Option 1</choice>
      <choice value="child2_1_2">Parent 2 Child 1 Option 2</choice>
    </input>

    <input type="checkbox" token="tokChild3_1" searchWhenChanged="true" depends="$showParent3$">
      <label>Child 1 of Parent 3</label>
      <choice value="child3_1_1">Parent 3 Child 1 Option 1</choice>
      <choice value="child3_1_2">Parent 3 Child 1 Option 2</choice>
    </input>
  </fieldset>
</form>
Cheers,
Jacob

If you feel this response answered your question, please do not forget to mark it as such. If it did not, but you do have the answer, feel free to answer your own post and accept that as the answer.
0 Karma

paviach
New Member

Thank you, @jacobevans . This helped out. Could you also please help me out how in restricting the panel unless it is being clicked? Currently the first panel in each list of checkboxes is loading without making a selection. Thanks again!

0 Karma

jacobpevans
Motivator

As an example, if your panel depends on Parent 3 Child 1 Option 2 in my example, add the following to my example:

 <input type="checkbox" token="tokChild3_1" searchWhenChanged="true" depends="$showParent3$">
   <label>Child 1 of Parent 3</label>
   <choice value="child3_1_1">Parent 3 Child 1 Option 1</choice>
   <choice value="child3_1_2">Parent 3 Child 1 Option 2</choice>
   <change>
     <condition value="child3_1_2">
       <set token="showchild3_1_2">true</set>
     </condition>
   </change>
 </input>

I did not test this as I did the other one, but hopefully you can follow the logic from there. Please take a look at the "Splunk Dashboard Examples" app here: https://splunkbase.splunk.com/app/1603/. Besides helping with your request, there is a copy and paste token debugger that you can plug into any dashboard to assist with debugging.

Splunk Answers keeps deleting my panel definition. It would be like: < panel depends = " $ showParent3 $ $ showchild3_1_2 $ " > without spaces (except between panel and depends).

Cheers,
Jacob

If you feel this response answered your question, please do not forget to mark it as such. If it did not, but you do have the answer, feel free to answer your own post and accept that as the answer.
0 Karma

paviach
New Member

Sorry if I wasnt clear but let me rephrase my questions.
I have 3 parent and options under each parent.

Say, parent1 is loaded by default with child1 (p1c1). When I select parent2, p1c1 should be disappearing. But unfortunately, p1c1 and p2c1 is on the page. Could we make p1c1 hide when parent2 is selected?

0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

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

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...