Dashboards & Visualizations

Submit button not working in drop down

kishan2356
Explorer

Hi,

I have a dashboard that consists of two text boxes, a drop-down menu, and a submit button.
The text boxes take in start time and end time. The drop-down menu holds multiple panels.

What we want is for the user to be able to enter a start time, end time, pick the option they want to
see in the drop-down menu, and then click the submit button.

What is happening now is the submit button is being ignored.
I have tried to change both the start date and end date text boxes to search WhenChanged="true" and search WhenChanged="false" but neither seems to work.

Is it possible for the submit button to be able to handle so many things?
If so please provide a way for the submit button to work.
If clarification is needed please ask and I will provide.

0 Karma

niketn
Legend

@kishan2356 this is an issue with <change> event handler updating both Submit and Default token models. Hence subsequent searches depending on tokens declared in change event handler run even without submit button. Refer to one of my older answers to understand this behavior and use and independent search to add dummy dependency to prevent searches based on dummy dependent tokens from running until submit button is clicked: https://answers.splunk.com/answers/742451/searchwhenchangedfalse-not-honored-1.html

On a different note refer to another one of my older answers to use jQuery Date picker in Splunk Dashboard which requires Simple XML JS extension: https://answers.splunk.com/answers/627432/jquery-datepicker-in-splunk.html

____________________________________________
| makeresults | eval message= "Happy Splunking!!!"

dindu
Contributor

Hi Kishan,

Once you correct the change handler,you should use $ to fetch the token values.

strptime($startdate$,"%m/%d/%Y %H:%M %p")
strptime($enddate$,"%m/%d/%Y %H:%M %p")

0 Karma

kishan2356
Explorer

Hey @dindu can you provide this as a example using the XML code I provided? thanks

0 Karma

dindu
Contributor

Hi @kishan2356,

You could use the below snippet.
I have included an option to display the values.You can remove it once you test the functionality.
[Remove the tags at the end]
Please upvote and accept if this helped!!

<fieldset submitButton="true" >
 <input type="text" token="startdate" searchWhenChanged="false" >
<label>Start Date (mm/dd/yyyy hh:mm)</label>
 <default></default>
 <change>
  <condition>
   <eval token="new_earliest">strptime($startdate$,"%m/%d/%Y %H:%M")</eval>
   <eval token="new_earliest1">strptime($startdate$,"%m/%d/%Y %H:%M")-604800</eval>
   <eval token="new_earliest2">strptime($startdate$,"%m/%d/%Y %H:%M")-1209600</eval>
   <eval token="new_earliest3">strptime($startdate$,"%m/%d/%Y %H:%M")-1814400</eval>
   <eval token="new_earliest4">strptime($startdate$,"%m/%d/%Y %H:%M")-2419200</eval>
 </condition>
</change>
</input>
<input type="text" token="enddate" searchWhenChanged="false"> 
<label>End Date (mm/dd/yyyy hh:mm)</label>
<default></default>
<change>
 <condition>
   <eval token="new_latest">strptime($enddate$,"%m/%d/%Y %H:%M")</eval>
   <eval token="new_latest1">strptime($enddate$,"%m/%d/%Y %H:%M")-604800</eval>
   <eval token="new_latest2">strptime($enddate$,"%m/%d/%Y %H:%M")-1209600</eval>
   <eval token="new_latest3">strptime($enddate$,"%m/%d/%Y %H:%M")-1814400</eval>
   <eval token="new_latest4">strptime($enddate$,"%m/%d/%Y %H:%M")-2419200</eval>
  </condition>
  </change>
 </input>
 <input type="dropdown" token="field1" searchWhenChanged="false">
<label>X</label>
<choice value="A">A</choice>
<choice value="B">B</choice>
<choice value="C">C</choice>
<choice value="D">D</choice>
<choice value="E">E</choice>
<choice value="F">F</choice>
<choice value="G">G</choice>
<choice value="H">H</choice>
<default>A</default>
</input>
</fieldset>
<row>
 <html>
 <li> X $field1$</li>
 <li>display startdate $startdate$</li>
 <li>display new_earliest $new_earliest$</li>
 <li>display new_earliest1 $new_earliest1$</li>
 <li>display new_earliest2 $new_earliest2$</li>
 <li>display new_earliest3 $new_earliest3$</li>
 <li>display new_earliest4 $new_earliest4$</li>
</html>
<html>
  <li>display enddate $enddate$</li>
  <li>display new_latest $new_latest$</li>
  <li>display new_latest1 $new_latest1$</li>
  <li>display new_latest2 $new_latest2$</li>
  <li>display new_latest3 $new_latest3$</li>
  <li>display new_latest4 $new_latest4$</li>
 </html>
</row>
0 Karma

nikita_p
Contributor

Hi kishan2356,

Is your search dependent on the tokens that you are applying?

0 Karma

vnravikumar
Champion

Hi

If possible can you please post your code.

0 Karma

kishan2356
Explorer

Ive added the code for the text boxes, drop down box and submit button below.

XX

<input type="text" token="startdate" searchWhenChanged="false">
  <label>Start Date (mm/dd/yyyy hh:mm)</label>
  <default></default>
  <change>
    <condition>
      <eval token="new_earliest">strptime(startdate,"%m/%d/%Y %H:%M %p")</eval>
      <eval token="new_earliest1">strptime(startdate,"%m/%d/%Y %H:%M %p")-604800</eval>
      <eval token="new_earliest2">strptime(startdate,"%m/%d/%Y %H:%M %p")-1209600</eval>
      <eval token="new_earliest3">strptime(startdate,"%m/%d/%Y %H:%M %p")-1814400</eval>
      <eval token="new_earliest4">strptime(startdate,"%m/%d/%Y %H:%M %p")-2419200</eval>
    </condition>
  </change>
</input>
<input type="text" token="enddate" searchWhenChanged="false"> 
  <label>End Date (mm/dd/yyyy hh:mm)</label>
  <default></default>
  <change>
    <condition>
      <eval token="new_latest">strptime(enddate,"%m/%d/%Y %H:%M %p")</eval>
      <eval token="new_latest1">strptime(enddate,"%m/%d/%Y %H:%M %p")-604800</eval>
      <eval token="new_latest2">strptime(enddate,"%m/%d/%Y %H:%M %p")-1209600</eval>
      <eval token="new_latest3">strptime(enddate,"%m/%d/%Y %H:%M %p")-1814400</eval>
      <eval token="new_latest4">strptime(enddate,"%m/%d/%Y %H:%M %p")-2419200</eval>
    </condition>
  </change>
</input>

<input type="dropdown" token="field1">
  <label>X</label>
  <choice value="A">A</choice>
  <choice value="B">B</choice>
  <choice value="C">C</choice>
  <choice value="D">D</choice>
  <choice value="E">E</choice>
  <choice value="F">F</choice>
  <choice value="G">G</choice>
  <choice value=”H">H</choice>
  <default>A</default>
  <change>
    <condition value="A">
      ……………………………………………………………………………………………………………………………………..
    </condition>
  </change>
</input>
0 Karma
Get Updates on the Splunk Community!

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...

Introducing the 2024 Splunk MVPs!

We are excited to announce the 2024 cohort of the Splunk MVP program. Splunk MVPs are passionate members of ...

Splunk Custom Visualizations App End of Life

The Splunk Custom Visualizations apps End of Life for SimpleXML will reach end of support on Dec 21, 2024, ...