PDA

View Full Version : Resolved Enable a form button after a short delay?



Chimpanzee
02-12-2010, 12:32 PM
Hi.

I'm trying to find a way to disable a 'Continue' button for 15 seconds or so after a page is loaded. Does anyone know how I might do this? I'm thinking of it working is a similar way to how Firefox disables the 'Ok' button for 3 seconds before allowing you to install a plugin, to encourage you to read the security warning.

Any suggestions would be much appreciated, however I know next to nothing about JS :). Thanks.

Nile
02-12-2010, 12:43 PM
Give the continue button the id of continue, and then insert this code below him:


<script type="text/javascript">
document.getElementById('continue').disabled = true;
setTimeout(function(){
document.getElementById('continue').disabled = false;
}, 15000);
</script>

Chimpanzee
02-12-2010, 01:28 PM
Give the continue button the id of continue, and then insert this code below him:


<script type="text/javascript">
document.getElementById('continue').disabled = true;
setTimeout(function(){
document.getElementById('continue').disabled = false;
}, 15000);
</script>


...and it's that easy! Thank you so much. I just altered it slightly:

<script type="text/javascript">
document.getElementById('continue').disabled = true;
document.getElementById('continue').value = "Please wait...";
setTimeout(function(){
document.getElementById('continue').disabled = false;
document.getElementById('continue').value = "Continue";
}, 15000);
</script>

Thanks! :)

Nile
02-14-2010, 12:14 AM
Glad to help you! Your welcome!

It seems your topic is solved... Please set the status to resolved.. To do this:
Go to your first post ->
Edit your first post ->
Click "Go Advanced" ->
Then in the drop down next to the title, select "RESOLVED"