当前位置: 代码迷 >> ASP.NET >> button enable是FALSE 经过5秒后使其enable为TRUE解决方案
  详细解决方案

button enable是FALSE 经过5秒后使其enable为TRUE解决方案

热度:1825   发布时间:2013-02-25 00:00:00.0
button enable是FALSE 经过5秒后使其enable为TRUE
button enable是FALSE 经过5秒后使其enable为TRUE

请问如何实现

------解决方案--------------------------------------------------------
<script type="text/javascript"> 
function restore() 

setTimeout( "document.getElementById('Button1').disabled=false;", 5000); 

</script> 

<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="this.disabled=true;restore();" />
------解决方案--------------------------------------------------------
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
var clock;
function restore()
{
var btn = document.getElementById('<%= Button1.ClientID %>');
if(btn.disabled == true)
btn.disabled = false;
clearTimeout(clock);

}
function JiaZai()
{
clock = setTimeout('restore()', 5000);
}
</script>

</head>
<body onload="JiaZai()">
<form id="form1" runat="server">
<div>
<input id="Button1" disabled="disabled" runat="server" type="button" />
</div>
</form>
</body>
</html>

------解决方案--------------------------------------------------------
HTML code
<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title></title></head><body><form id="form1" name="form1" method="post" action=""> <input type="submit" name="Submit" value="同意" /></form><script language="javascript">document.form1.Submit.disabled = true;var speed = 1000; //速度var wait = 5; //停留时间function updateinfo(){  if(wait == 0){    document.form1.Submit.value = "我同意";    document.form1.Submit.disabled = false;  }  else{    document.form1.Submit.value = "阅读条款"+wait;    wait--;    window.setTimeout("updateinfo()",speed);  }}updateinfo();</script></body></html>
  相关解决方案