clear button

How to add a clear button to a filter select list.

Overview

The issue occurs because a static select list filter lacks a method to reset its selection.
Add an empty option to the select list and use JavaScript to reset the dropdown when the clear button is clicked, or include a specific parameter in the URL to clear the filter value.

Answered
ch chrissy6930 15 Mar, 2015
hi all,

I have added a filter with a static select list to my list of entries and would now like to add a clear button to it.

this is my code so far:
<select name="fltr[Entries][type]" id="fltr[Entries][type]">
  <option value='0' ><?php echo JText::_('OPTION0'); ?></option>
  <option value='1' ><?php echo JText::_('OPTION1'); ?></option>
  <option value='2' ><?php echo JText::_('OPTION2'); ?></option>
</select>
<input type='submit' name='filter' id='filter' value='Filter' />
 <input type='button' name='clear' id='clear' value='Clear' />


could somebody pls advice how to get the clear button to work pls? I suppose I need some JS...

best regards
Gabriela
Max_admin Max_admin 15 Mar, 2015
Answer
Hi Gabriela,

If you have an empty option and the user selects it then the filter should be cleared.

If you want to do this automatically using a button then you still need to add an empty value and reset the dropdown when the button is clicked, or try a link to the connection and add this to the url:

&fltr[Entries][type]=


Which should have the same effect!

regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.