views:

67

answers:

1

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?

+2  A: 
onchange='if(this.options[this.selectedIndex].value!=''){ this.form.submit(); }'
oezi