Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Javascript] code: disable & re-enable button


  • From: ShawnMilo at runbox.com (Shawn Milo)
  • Subject: [Javascript] code: disable & re-enable button
  • Date: Thu Aug 12 14:23:57 2004

Here it is:

In the <form> tag of the main page:
onsubmit="this.btnSubmit.disabled = true;"

Doing it in the form tag was necessary because doing it in the onclick
of the button cancels the form submission, and I didn't want to have to
use another function in my .js include file.

In the target window of the submitted form:

<body onload="window.focus();  
window.opener.document.forms['frmStats'].btnSubmit.disabled = false; ">



This does the trick.  If the window has not been opened yet, it pops up in
front.  If it's hiding in the background, the button is disabled until it loads,
which obscures the main window anyway.  Next time they go back to the
main page, the button is enabled again.

Now, the only problem here is if the second page blows up, due to some
error with the database or something.  I'll have to put something in there
to reset the button after 10 seconds or so.

Shawn