I want a submit button to be disabled for 4 seconds after the page begins to load... how do i do that? I don't have experience with javascript
I've made a working example for you: <html> <head> <script type="text/javascript"> function text_enable() { document.formname.textname.disabled=false; document.formname.submitname.disabled=false; } </script> </head> <body onLoad="window.setTimeout('text_enable()',4000);"> <form method="get" name="formname" action="http://www.YourSite.com"> <input type="text" name="textname" size="24" maxlength="255" value="testing value"/> <input type="submit" name="submitname" value="TEST" disabled="true"/> </form> </body> </html> Code (markup):
ajsa52, you are disabling it with html and enabling it with javascript, what about these visitors that dont have js enabled? is there a way to disable a button with js instead of the disabled=true attr?
Well, with my previous example you're "forcing" the visitor to Enable javascript. I you want your button enabled for visitor with javascript disabled, you can use something like this: <html> <head> <script type="text/javascript"> function form_enable() { document.formname.textname.disabled=false; document.formname.submitname.disabled=false; } function form_disable() { document.formname.textname.disabled=true; document.formname.submitname.disabled=true; } </script> </head> <body onLoad="form_disable(); window.setTimeout('form_enable()',4000);"> <form method="get" name="formname" action="http://www.YourSite.com"> <input type="text" name="textname" size="24" maxlength="255" value="testing value"/> <input type="submit" name="submitname" value="TEST"/> </form> </body> </html> Code (markup):