All,
I can reset all my form elements using the following JQuery Syntax:
('#myform')[0].reset();
How can I modify this to exclude the reset of "select box" values?
Thanks
To everyone..
the reset function does not set everything to '' (empty string)
it reset to their initial values .. (stored in the value attribute, or selected option etc..)
If you want to maintain the default reset features then you should
<select>
elementsexample:
<script type="text/javascript">
$(document).ready(
function(){
$("#resetbutton").click(
function(){
var values = [];
var selected = $("select").each(
function(){
values.push( $(this).val());
});
this.form.reset();
for (i=0;i<selected.length;i++)
$(selected[i]).val(values[i]);
});
}
);
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With