We help IT Professionals succeed at work.

Enable button after some seconds

Sharalynn
Sharalynn asked
on
949 Views
Last Modified: 2009-12-16
I need a button disabled, then wait some time (either random seconds or say, 5 seconds), before it changes text to "You may now proceed" and enable the button. Is it doable with OnClientClick or some sort?
Comment
Watch Question

Jorge PaulinoIT Pro/Developer
CERTIFIED EXPERT
Top Expert 2008

Commented:
If you use AJAX you can add a timer to your asp.net project.
CERTIFIED EXPERT

Commented:
string script = @"<script language ='javascript'>
                    document.getElementById('btnNext').disabled = 1;  
                    window.setTimeout('enable()', 3000)
                    function enable()
                        {
                    document.getElementById('btnNext').disabled = 0;  
                        }
                    </script>";
                Page.RegisterStartupScriptBlock("click", script);



http://forums.asp.net/p/914726/1034336.aspx
Jorge PaulinoIT Pro/Developer
CERTIFIED EXPERT
Top Expert 2008

Commented:

Author

Commented:
Not AJAX website.

Old code from asp.net

Too advanced :(
Jorge PaulinoIT Pro/Developer
CERTIFIED EXPERT
Top Expert 2008

Commented:
>> Too advanced :(

I had the feeling but after install the ajax and ajax toolkit I found very easy to handle. Is just some extra control that will improve your pages.

Author

Commented:
But I don't want to implement ajax at all. There must be some other way of doing so easily

Commented:
Someone already posted the solution for you. it just needed a little modifying.


<script language ='javascript'>
function disable(){
  document.getElementById('btnNext').disabled = 1;  
  window.setTimeout('enable()', 3000)                  
}
function enable(){
  document.getElementById('btnNext').disabled = 0;  
}
</script>
<input type="button" id="btnNext" onClick="javascript:disable()" value="Clickme">

Open in new window

Author

Commented:
Thanks mixart, how would I do it for page load instead of button click?
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION