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

View solution in original post

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
.conf21 Now Fully Virtual!
Register for FREE Today!

We've made .conf21 totally virtual and totally FREE! Our completely online experience will run from 10/19 through 10/20 with some additional events, too!