Splunk Dev

Dependent dropdown auto population

ND
Path Finder

Hello All,

I am new to Splunk and JavaScript as well.

I need help to auto-populate the dropdown list value based on other dropdown values selected.

consider, I have 3 fields Country, State, City which are interdependent on each other.

I am able to populate a dynamic dropdown list(for 2 fields like State & City) on the selection of another dropdown (Country).

Now I want to auto-populate values of State and Country on the selection of any City. Values should be directly displayed in the drop-down box. there should not be a need to select it from the dropdown. As for City, State & Country is going to be unique values.

Thanks in Advance!!!

Labels (1)
Tags (2)

to4kawa
Ultra Champion
<form>
  <label>multi dynamic select</label>
  <search id="base_csv">
    <query>| inputlookup geo_attr_us_states.csv
| rex field=state_name "(?&lt;Capital&gt;\w)"
</query>
    <earliest>-24h@h</earliest>
    <latest>now</latest>
  </search>
  <fieldset submitButton="false">
    <input type="dropdown" token="field1">
      <label>field1</label>
      <fieldForLabel>Capital_string</fieldForLabel>
      <fieldForValue>Capital</fieldForValue>
      <search base="base_csv">
        <query>| stats values(Capital) as Capital |mvexpand Capital | eval Capital_string=Capital</query>
      </search>
    </input>
    <input type="dropdown" token="field2">
      <label>field2</label>
      <fieldForLabel>state_code_name</fieldForLabel>
      <fieldForValue>state_code</fieldForValue>
      <search base="base_csv">
        <query>| search Capital="$field1$"
| table state_code
| eval state_code_name=state_code</query>
      </search>
    </input>
  </fieldset>
  <row>
    <panel>
      <table>
        <search base="base_csv">
          <query>| search state_code="$field2$"</query>
        </search>
      </table>
    </panel>
  </row>
</form>

this is sample code.
You can do something like this without using javascript.

Get Updates on the Splunk Community!

Observability Unlocked: Kubernetes & Cloud Monitoring with Splunk IM

Ready to master Kubernetes and cloud monitoring like the pros? Join Splunk’s Growth Engineering team on ...

Index This | What did the zero say to the eight?

June 2025 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with this month’s ...

Splunk Observability Cloud's AI Assistant in Action Series: Onboarding New Hires & ...

This is the fifth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...