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
Influencer

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

tscroggins
Influencer

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.

Get Updates on the Splunk Community!

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...

Share Your Ideas & Meet the Lantern team at .Conf! Plus All of This Month’s New ...

Splunk Lantern is Splunk’s customer success center that provides advice from Splunk experts on valuable data ...