I have a form I have built:
<form class="myform" action="cgi.pl">
<select name="export" onchange='this.form.submit()'>
<option value="" selected="selected">Choose an export format</option>
<option value="html">HTML</option>
<option value="csv">CSV</option>
</select>
</form>
Now, this form works fine if I pull down and select "HTML" or "CSV". But if I hit the back button and select "Choose an export format", the form is submitted, even though I dont want it to be.
Is there any way to prevent form submission for that option?
onchange='if(this.options[this.selectedIndex].value!=''){ this.form.submit(); }'
$("select[name=export]").on("change", function(e) {
if ($(this).val() != "") {
$("form.myform").submit();
}
});
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