Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling button with javascript: FF vs IE

I have a row of buttons, which all create a pdf file which I want to open in a new tab. This way the button page stays on top, and the pdf's open to get printed. To prevent clicking a button twice I disable the button, like this (I use python):

<input type='submit' value='Factureren' name='submitbutton' id='%s'
onclick="javascript:document.getElementById('%s').disabled=true; 
document.getElementById('%s').className='button_disabled';"> % ((but_id,) *3)

In FF3 this works fine, i.e. the form is submitted, the script executed and then the button disables. In IE the button just disables, but the form script isn't executed.

Is there a solution to this IE problem?

like image 837
user37986 Avatar asked Dec 05 '22 07:12

user37986


1 Answers

It is easy: a disabled submit button do not submit a form in IE. Consider to restructure your code:

  • Use a regular button, disable it, and call form.submit() from its handler.
  • Do not disable the button in its "onclick", but save it, and do it in form's onsubmit.
like image 61
Eugene Lazutkin Avatar answered Dec 23 '22 17:12

Eugene Lazutkin