Getting Data In

How to control the default in a dropdown menu

HattrickNZ
Motivator

I have the following dropdown menu:

  <fieldset autoRun="true" submitButton="false">
    <input type="dropdown" token="select_wday">
      <label>Select Day:</label>
      <choice value="Mon">Mon</choice>
      <choice value="Tue">Tue</choice>
      <choice value="Wed">Wed</choice>
      <choice value="Thu">Thu</choice>
      <choice value="Fri">Fri</choice>
      <choice value="Sat">Sat</choice>
      <choice value="Sun">Sun</choice>
      <default>Fri</default>
    </input>
  </fieldset>

The default in the drop-down above would be Friday. Is there a way I could control it that if the user visited the dashboard on a Wednesday the would Wednesday as the value in the drop-down menu?

I am thinking something liket the below which I have used to populate a checkbox, but I have not used it to set the default.

           <populatingSearch fieldForValue="userLabel" fieldForLabel="userLabel" earliest="-24h" latest="now">
        <![CDATA[
<search goes here that would give the current day of the week>
        ]]>
      </populatingSearch>
0 Karma
1 Solution

PowerPacked
Builder

Hi @HattrickNZ

give this a try

<dashboard>
  <label>check123</label>
      <search>
      <query>|makeresults  | eval Date=strftime(_time," %a") | table Date</query>
          <earliest>-15m</earliest>
          <latest>now</latest>
          <finalized >
                     <condition match=" 'job.resultCount' != 0">
                             <set token="Date">$result.Date$</set>
                      </condition>
           </finalized >           
    </search>
     <fieldset autoRun="true" submitButton="false">
     <input type="dropdown" token="select_wday">
       <label>Select Day:</label>
       <choice value="Mon">Mon</choice>
       <choice value="Tue">Tue</choice>
       <choice value="Wed">Wed</choice>
       <choice value="Thu">Thu</choice>
       <choice value="Fri">Fri</choice>
       <choice value="Sat">Sat</choice>
       <choice value="Sun">Sun</choice>
       <default>$Date$</default>
     </input>
   </fieldset>
</dashboard>

Thanks

View solution in original post

PowerPacked
Builder

Hi @HattrickNZ

give this a try

<dashboard>
  <label>check123</label>
      <search>
      <query>|makeresults  | eval Date=strftime(_time," %a") | table Date</query>
          <earliest>-15m</earliest>
          <latest>now</latest>
          <finalized >
                     <condition match=" 'job.resultCount' != 0">
                             <set token="Date">$result.Date$</set>
                      </condition>
           </finalized >           
    </search>
     <fieldset autoRun="true" submitButton="false">
     <input type="dropdown" token="select_wday">
       <label>Select Day:</label>
       <choice value="Mon">Mon</choice>
       <choice value="Tue">Tue</choice>
       <choice value="Wed">Wed</choice>
       <choice value="Thu">Thu</choice>
       <choice value="Fri">Fri</choice>
       <choice value="Sat">Sat</choice>
       <choice value="Sun">Sun</choice>
       <default>$Date$</default>
     </input>
   </fieldset>
</dashboard>

Thanks

HattrickNZ
Motivator

that's kind of it.

but it is putting a space(%20) before the Fri

for example the url goes to this
/check123?form.select_wday=%20Fri

and if I wanna pass the select_wday to other panels further down it puts the space in front of Fri.
Any way to not add the space?
tks

0 Karma

PowerPacked
Builder

extra space was added in | eval Date=strftime(_time," %a")

try taking out the space as this ---- | eval Date=strftime(_time,"%a")

Thanks

HattrickNZ
Motivator

tks missed that!

0 Karma

pradeepkumarg
Influencer
|makeresults  | eval Date=strftime(_time," %a") | table Date

pradeepkumarg
Influencer

This will give you the complete list with first option as Today's

|makeresults  | eval Date=strftime(_time," %a") | table Date
| append [|gentimes start=10/28/07 | head 7 | eval Date=strftime(endtime," %a") | table Date] | dedup Date

HattrickNZ
Motivator

tks, my question was more around the xml part. how should the xml code look?

0 Karma
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 ...