Dashboards & Visualizations

Set token value for unchecked box?

matstap
Communicator

I'm trying to set a token value for an unchecked box. I want it to be such that when it's clicked, it has value A, and when it is unchecked it has value B.

Is there a way to do this without involving javascript?

1 Solution

micahkemp
Champion

It sounds like you would be better served using a dropdown, if there are two choices that aren’t essentially true or false.

But, you can accomplish this with a checkbox, as this run-anywhere example shows:

<form>
  <label>Set value by checkbox</label>
  <fieldset submitButton="false">
    <input type="checkbox" token="checked" searchWhenChanged="true">
      <label></label>
      <choice value="yes">Check for A</choice>
      <delimiter> </delimiter>
      <change>
        <condition value="yes">
          <eval token="checked_result_value">"A"</eval>
        </condition>
        <condition>
          <eval token="checked_result_value">"B"</eval>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <single>
        <search>
          <query>| makeresults | eval value="$checked_result_value$"</query>
        </search>
      </single>
    </panel>
  </row>
</form>

View solution in original post

micahkemp
Champion

It sounds like you would be better served using a dropdown, if there are two choices that aren’t essentially true or false.

But, you can accomplish this with a checkbox, as this run-anywhere example shows:

<form>
  <label>Set value by checkbox</label>
  <fieldset submitButton="false">
    <input type="checkbox" token="checked" searchWhenChanged="true">
      <label></label>
      <choice value="yes">Check for A</choice>
      <delimiter> </delimiter>
      <change>
        <condition value="yes">
          <eval token="checked_result_value">"A"</eval>
        </condition>
        <condition>
          <eval token="checked_result_value">"B"</eval>
        </condition>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <single>
        <search>
          <query>| makeresults | eval value="$checked_result_value$"</query>
        </search>
      </single>
    </panel>
  </row>
</form>

micahkemp
Champion

Added example of doing this with a checkbox, despite it potentially not being the best tool for the job.

0 Karma

matstap
Communicator

This is what I was looking for. Thanks

0 Karma
Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...