I am working on a use case where I have 3 radio buttons ( say 2001, 2002 and Today) and one drop-down. Clicking on the 2002 radio button should display all the movie releases occurred in that year ( let's say MovieA , MovieB , MovieC ). Now, in the drop-down, select MovieB so now drop-down displays MovieB. Now, click on other radio button, let's say, 2001. So at this time, the drop-down should populate all the releases that occurred in the year 2001, and it should not retain the previously selected value in the drop-down which in this case would be MovieB. I am fine with having one default value ( which would show up in the drop-down, something like "Please select Value", and when clicking on the drop-down arrow, you can see all movies of that year ) for all radio buttons as long as it does NOT retain the previously selected value in the drop-down.
My code is attached below.
< fieldset submitButton="false">
< input type="radio" token="event_date_type2" searchWhenChanged="true">
< default>Today < /default>
< earliest>-24h< /earliest>
< latest>now< /latest>
< populatingSearch fieldForValue="event_date_type2" fieldForLabel="event_date_type2">
< ![CDATA[| inputlookup file.csv | FIELDS event_date_type2 |
eval event_date_type2 = substr(event_date_type2,0,4) | dedup
event_date_type2
|where event_date_type2!=0 | append [ inputlookup
Events_Lookup_20141001.csv |stats count |eval event_date_type2="Today"
| FIELDS event_date_type2] ]]>
< /populatingSearch >
< /input>
< input type="dropdown" token="field2" searchWhenChanged="false">
< label>Select a Date</label>
< search>
< query>|inputlookup Events_Lookup_20141001.csv | where like(event_date,"%$event_date_type2$%") | append [ inputlookup Events_Lookup_20141001.csv |stats count |eval event_date_type2="%$event_date_type2$%" | eval title="Today"| eval latest_timestamp =strftime(now(),"%s") | eval earliest_timestamp = now()-86400 ] | where like(title, "%$event_date_type2$%")
< /query>
< /search>
< fieldForLabel>title< /fieldForLabel>
< fieldForValue>title< /fieldForValue>
< default>Please select Value < /default> // This is default value to be shown un in dropdown as soon as radio button pressed.
< change>
< set token="field2.earliest">$row.earliest_timestamp$< /set>
< set token="field2.latest">$row.latest_timestamp$< /set>
< /change>
Truly appreciate your help on this fix. Please let me know what am I missing here.
Thank you.
I'm not sure this can be done without Javascript.
In Javascript, you can simply listen to a change of the radio buttons and in that case set the selection of the dropdown to the standard selection. If you are interested, you might want to have a look here and here.
By the way, if you're looking for a way to "clear" the dropdown, you should put something like "Any" as label and use *
as value; in most search scenarios, this should have the effect of "nothing selected" on a search (i.e. index = foo movie_title=$dropdown$
with $dropdown$
replaced by *
does not filter anything besides events whithout the field movie_title
). That way, the user doesn't even have to select something from the dropdown in order to see results.
Thank you for your response. Yes, I did try that too but did not see expected experience. However, was able to handle this through XML itself. No need of JS.
I am facing the same issue .........can you share the answer..........?
Good - then you could consider sharing your solution for others to see 🙂