Splunk Search

How to customize panel popup based on checkboxes?

mahesh27
Communicator

I have few checkboxes where my panels are getting displayed when i select them and if i unselct them they are not appearing , till hear i am good but my requirement is

under mainframe i have 2 checkboxes source and destination
under services i have 6 checkboxes service1, service2......
under items  i have 4 checkboxes item1, item2....

So here ,
service1, service2 and service 3, item1, item 2 belongs to source
service4, service5 and service 6, item3, item 4 belongs to destination

So my panels should display when i select source, service1, item1 check box only.

Main frame         services         items     
 
source                     service1      item1
destination           service2       item2
                                   service3      item3
                                   service4      item4
                                   service5      
                                   service6

How can i do that?????

0 Karma

yuanliu
SplunkTrust
SplunkTrust

You need two elements:

  • Populate (set and unset) a dedicated token to control that panel, perhaps in <condition><set token/></condition> blocks in <input/> or <init/>. (If inside <input />, see Define tokens for conditional operations with form inputs.)
  • Use that token as values for "depends" attribute of the display element.

See Show or hide content.  Actual coding takes some practice.  There are many examples in this forum, too.

0 Karma

mahesh27
Communicator

so here is my code, can u help me on this:
<form>
<label></label>
<fieldset submitbutton="false">
<input type="checkbox"  token="check" searchwhenchanged=true>
<label>source details</label>
<choice value=sourcetype=afv OR sourcetype=afv ght OR sourcetype=afv jhy> source</choice>
<choice value=sourcetype=aaa OR sourcetype=aaabgth OR sourcetype=aaajuk> destination</choice>
<change>
<condition match =$check$ == *afv*>
<set token=src>1</set>
<unset token=dst></unset>
</condition>
<condition match =$check$ == *aaa*>
<set token=dst>1</set>
<unset token=src></unset>
</condition>
<condition match =$check$ == *afv*>
<set token=src>1</set>
<set token=dst>1</set>
</condition>
</change>
<row>
<panel depends="$src$">
<title></tilte>
<search>
<query>.....</query>
</form>

0 Karma

yuanliu
SplunkTrust
SplunkTrust

Just make sure you open and close XML tags properly, and note that some special characters must be represented as HTML entities; e.g., quotation mark (") must be represented as &quot;.

This is a test dashboard based on your code to play with.

<form version="1.1">
  <label>test hiding</label>
  <description></description>
  <search>
    <query>.....</query>
  </search>
  <fieldset>
    <input type="checkbox" token="check" searchWhenChanged="true">
      <label>check</label>
      <choice value="sourcetype=&quot;afv&quot; OR sourcetype=&quot;afv ght&quot; OR sourcetype=&quot;afv jhy&quot;">source</choice>
      <choice value="sourcetype=&quot;aaa&quot; OR sourcetype=&quot;aaabgth&quot; OR sourcetype=&quot;aaajuk&quot;">destination</choice>
      <change>
        <condition match="match($check$, &quot;afv&quot;)">
          <set token="src">1</set>
          <unset token="dst"></unset>
        </condition>
        <condition match="match($check$, &quot;aaa&quot;)">
          <set token="dst">1</set>
          <unset token="src"></unset>
        </condition>
        <condition match="$check$ == &quot;*afv*&quot;">
          <set token="src">1</set>
          <set token="dst">1</set>
        </condition>
      </change>
      <delimiter> </delimiter>
    </input>
  </fieldset>
  <row>
    <panel depends="$src$">
      <html>
        <p>test</p>
        <br>check: $check$</br>
      </html>
    </panel>
  </row>
</form>
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!

[Puzzles] Solve, Learn, Repeat: Character substitutions with Regular Expressions

This challenge was first posted on Slack #puzzles channelFor BORE at .conf23, we had a puzzle question which ...

Splunk Community Badges!

  Hey everyone! Ready to earn some serious bragging rights in the community? Along with our existing badges ...

[Puzzles] Solve, Learn, Repeat: Matching cron expressions

This puzzle (first published here) is based on matching timestamps to cron expressions.All the timestamps ...