I have a reset button in a form
<input type="reset" value="Reset">
and some selections
<select>
<option value="0">A</option>
<option value="10" selected="selected">B</option>
</select>
If I click on reset nothing happens. Here is an example.
Edit: I thought that the reset button will reset to the first value of a selection list. It seems that was a missunderstanding of my side. I want to reset to the first element of a selection.
So is the only way to create a reset function in Javascript? What if the user has turned off Javascript?
I have a reset button in a form
<input type="reset" value="Reset">
and some selections
<select>
<option value="0">A</option>
<option value="10" selected="selected">B</option>
</select>
If I click on reset nothing happens. Here is an example.
Edit: I thought that the reset button will reset to the first value of a selection list. It seems that was a missunderstanding of my side. I want to reset to the first element of a selection.
So is the only way to create a reset function in Javascript? What if the user has turned off Javascript?
Share Improve this question edited Jul 29, 2012 at 10:21 Mat 207k41 gold badges402 silver badges418 bronze badges asked Apr 6, 2012 at 8:30 testingtesting 20.3k54 gold badges243 silver badges432 bronze badges 7- Then you are SOL. -You COULD make the reset a submit button that requested a new form with the selected on item 0 – mplungjan Commented Apr 6, 2012 at 8:31
-
@testing, your fiddle works for me on Firefox 10 (selecting another option then clicking
Reset
restoresproduct a
as the selected value). What browser are you using? – Frédéric Hamidi Commented Apr 6, 2012 at 8:33 -
What is SOL? I'm using Firefox 11, Chrome 17, IE 9 ... I've bad experiences with multiple submit buttons, because
this.form.submit();
doesn't work anymore. Product a is selected per default. When the user clicks on Reset it should show "-none-". – testing Commented Apr 6, 2012 at 8:53 -
2
@testing, this is not the way
reset
buttons work. The value that was initially selected when the page loaded will be restored, not the first value of the list. – Frédéric Hamidi Commented Apr 6, 2012 at 8:55 - So how can I reset to the first value of the list? – testing Commented Apr 6, 2012 at 8:58
2 Answers
Reset to default 3Force value to nothing of all inputs, select, etc...
$("#filter_form").find("select, input, checkbox").val("");
When I click on reset button, form reset in defaults. It's working in your example (option 10 is default).