Dashboards & Visualizations

Pass Text box value to radio button

mnj1809
Path Finder

Hello,

I need help to assign text box value to radio button but it's not working.

mnj1809_0-1709902339194.png

 

 

<form>
<label>assign text box value to Radio button</label>
<fieldset submitButton="false">
<input type="radio" token="tokradio" searchWhenChanged="true">
<label>field1</label>
<choice value="category=$toktext$">Group</choice>
<default>category=$toktext$</default>
<initialValue>category=$toktext$</initialValue>
</input>
<input type="text" token="toktext" searchWhenChanged="false">
<label>field2</label>
</input>
</fieldset>
<row>
<panel>
<title>tokradio=$tokradio$</title>
<table>
<search>
<query>| makeresults</query>
<earliest>-24h@h</earliest>
<latest>now</latest>
</search>
<option name="drilldown">none</option>
</table>
</panel>
</row>
</form>

 


Thanks in advance.

@bowesmana  @tscroggins @gcusello @yuanliu @ITWhisperer 

Labels (1)
0 Karma
1 Solution

tscroggins
Champion

Hi @mnj1809,

The choice element value attribute is a literal string. The string is compared against the current token value to determine which radio button is selected.

For example:

<input type="radio" token="tokradio">
  <choice value="1">One</choice>
  <choice value="2">Two</choice>
  <choice value="3">Three</choice>
  <default>1</default>
</input>

The default value of $tokradio$ is 1, and choice One is selected. If either a user interaction or dashboard code sets the value of $tokradio$ to 2 or 3, choice Two or Three is selected, respectively. If $tokradio$ is set to a value other than the value attributes defined in the choice list, e.g. 4, no choice is selected.

If your goal is to user a radio input to select field names and a text input to enter field values, you can define and update a separate field when either token changes:

<form version="1.1" theme="light">
  <label>mnj1809_radio</label>
  <init>
    <set token="tokradiotext">$tokradio$="$toktext$"</set>
  </init>
  <fieldset submitButton="false">
    <input type="radio" token="tokradio">
      <label>Field</label>
      <choice value="category">Group</choice>
      <choice value="severity">Severity</choice>
      <default>category</default>
      <change>
        <set token="tokradiotext">$value$="$toktext$"</set>
      </change>
    </input>
    <input type="text" token="toktext">
      <label>Value</label>
      <default>*</default>
      <change>
        <set token="tokradiotext">$tokradio$="$value$"</set>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <event>
        <title>tokradiotext=$tokradiotext$</title>
        <search>
          <query>| makeresults</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
      </event>
    </panel>
  </row>
</form>

 

View solution in original post

0 Karma

Stopplis
Explorer

Nice solution. I'm, working with similar situation. What does this situation look like with checkbox?

0 Karma

tscroggins
Champion

Hi @Stopplis,

Similar but with input type=checkbox. If you need examples, please post a new question with more detail, and I (or someone else if they get to it first) will be happy to help.

Edit: Looks like you did and have an answer pending. Enjoy!

0 Karma

tscroggins
Champion

Hi @mnj1809,

The choice element value attribute is a literal string. The string is compared against the current token value to determine which radio button is selected.

For example:

<input type="radio" token="tokradio">
  <choice value="1">One</choice>
  <choice value="2">Two</choice>
  <choice value="3">Three</choice>
  <default>1</default>
</input>

The default value of $tokradio$ is 1, and choice One is selected. If either a user interaction or dashboard code sets the value of $tokradio$ to 2 or 3, choice Two or Three is selected, respectively. If $tokradio$ is set to a value other than the value attributes defined in the choice list, e.g. 4, no choice is selected.

If your goal is to user a radio input to select field names and a text input to enter field values, you can define and update a separate field when either token changes:

<form version="1.1" theme="light">
  <label>mnj1809_radio</label>
  <init>
    <set token="tokradiotext">$tokradio$="$toktext$"</set>
  </init>
  <fieldset submitButton="false">
    <input type="radio" token="tokradio">
      <label>Field</label>
      <choice value="category">Group</choice>
      <choice value="severity">Severity</choice>
      <default>category</default>
      <change>
        <set token="tokradiotext">$value$="$toktext$"</set>
      </change>
    </input>
    <input type="text" token="toktext">
      <label>Value</label>
      <default>*</default>
      <change>
        <set token="tokradiotext">$tokradio$="$value$"</set>
      </change>
    </input>
  </fieldset>
  <row>
    <panel>
      <event>
        <title>tokradiotext=$tokradiotext$</title>
        <search>
          <query>| makeresults</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
      </event>
    </panel>
  </row>
</form>

 

0 Karma

mnj1809
Path Finder

Thank you so much @tscroggins . It's working fine.

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!

Index This | What travels the world but is also stuck in place?

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

Discover New Use Cases: Unlock Greater Value from Your Existing Splunk Data

Realizing the full potential of your Splunk investment requires more than just understanding current usage; it ...

Continue Your Journey: Join Session 2 of the Data Management and Federation Bootcamp ...

As data volumes continue to grow and environments become more distributed, managing and optimizing data ...