Link to home
Start Free TrialLog in
Avatar of Sharalynn
SharalynnFlag for United States of America

asked on

Enable button after some seconds

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?
Avatar of Jorge Paulino
Jorge Paulino
Flag of Portugal image

If you use AJAX you can add a timer to your asp.net project.
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
Avatar of Sharalynn

ASKER

Not AJAX website.

Old code from asp.net

Too advanced :(
>> 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.
But I don't want to implement ajax at all. There must be some other way of doing so easily
Avatar of mixart
mixart

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

Thanks mixart, how would I do it for page load instead of button click?
ASKER CERTIFIED SOLUTION
Avatar of mixart
mixart

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial