How to add radio buttons
This documentation does not apply to the most recent version of Splunk. Click here for the latest version.
Contents
How to add radio buttons
Create a form search with dynamically populated radio buttons. You can specify a search to autopopulate radio button choices. Form search users can use the radio buttons to drive their search results.
Start your radio button form
Take the form search you've already created:
<form>
<label>Username</label>
<searchTemplate>sourcetype=logins $username$</searchTemplate>
<fieldset>
<input type="text" token="username" />
</fieldset>
<row>
<event>
<option name="count">100</option>
</event>
</row>
</form>
Now, change the <input type="text"> tag to radio and add a populatingSearch to generate the options for the radio buttons:
<input type="radio" token="username">
<label>Select Name</label>
<populatingSearch fieldForValue="suser" fieldForLabel="suser"><![CDATA[sourcetype=p4change | rex "user=(?<suser>\w+)@"
| stats count by suser]]></populatingSearch>
</input>
The end result is:
<input type="radio" token="username">
<label>Select Name</label>
<populatingSearch fieldForValue="suser" fieldForLabel="suser"><![CDATA[sourcetype=p4change | rex "user=(?<suser>\w+)@"
| stats count by suser]]></populatingSearch>
<default>nagrin</default>
<choice value="*">Any</choice>
</input>
<row>
<table>
<title>Users</title>
<option name="showPager">true</option>
</table>
</row>
Configuration options
There are more configuration options you can set on <code<input type=radio></code>. For example, you can add a label to appear next to the radio buttons, or specify a search to populate the radio buttons, etc. None of these options are required, but they do make the radio buttons more useful.
Here are all your options for configuration:
- label = label
- A label to place next to the generated dropdown.
- default = option
- The default option to select. If the default option cannot be found, the first option is selected.
- prefix
- See description for input type="text".
- suffix
- See description for input type="text".
- choice
- Requires a value attribute. eg "bar". A radio button option declared by the user. These appear in the order they are defined and before any options generated by an underlying search.
- populatingSearch
- A search used to generate fields for the radio buttons. Requires the attributes "fieldForValue" and "fieldForLabel". fieldForValue is the field extracted from the populatingSearch and placed in the value of the generated radio button option. fieldForLabel is the field extracted from the populatingSearch and placed in the label of the generated radio buttons.
- populatingSavedSearch
- Any saved search used to generate fields for the radio buttons. Requires the attributes "fieldForValue" and "fieldForLabel". fieldForValue is the field extracted from the populatingSavedSearch and placed in the value of the generated radio button option. fieldForLabel is the field extracted from the populatingSavedSearch and placed in the label of the generated radio buttons.
- earliest
- Earliest time set in Splunk time format.
- latest
- Latest time set in Splunk time format.
This documentation applies to the following versions of Splunk: 4.1 , 4.1.1 , 4.1.2 , 4.1.3 , 4.1.4 , 4.1.5 , 4.1.6 , 4.1.7 , 4.1.8 View the Article History for its revisions.