回复 10# hmhz 的帖子
版主幫看下4楼的那个代码4楼这个代码是我想要的,不过我試了一下,这段代码我放在form表单里它就失效了,是怎么回事?
<script language="javascript"> var Sec=0; var disabledTime; function Page_Load(){ disabledTime=window.setTimeout("Page_Load()",1000); Sec++; var input=document.getElementById("form1").getElementsByTagName("input"); for(var i=0;i<input.length;i++){if(input[i].disabled) input[i].value="已经过去了:"+Sec+"秒";} switch(Sec){ case 5: input[0].disabled=false; input[0].value=""; break; case 10: input[1].disabled=false; input[1].value=""; break; case 15: input[2].disabled=false; input[2].value=""; window.clearTimeout(disabledTime); break; } } </script> <body onLoad="Page_Load();"> <form id="form1" method="post"> <input type="text" name="InpTxt" disabled >文本框0<br> <input type="text" name="InpTxt" disabled >文本框1<br> <input type="text" name="InpTxt" disabled >文本框2<br> </form> </body>
<script language="javascript"> var Sec=0; var disabledTime; function Page_Load(){ disabledTime=window.setTimeout("Page_Load()",1000); Sec++; var input=document.getElementById("form1").getElementsByTagName("input"); for(var i=0;i<input.length;i++){if(input[i].disabled) input[i].value="已经过去了:"+Sec+"秒";} switch(Sec){ case 5: input[0].disabled=false; input[0].value=""; break; case 10: input[1].disabled=false; input[1].value=""; break; case 15: input[2].disabled=false; input[2].value=""; window.clearTimeout(disabledTime); break; } } </script> <body onLoad="Page_Load();"> <form method="POST"> <table border="0" width="100%" id="table8" cellspacing="1" cellpadding="5" bgcolor="#CCCCCC"> <tr> <td bgcolor="#FFFFFF" align="center" colspan="2"> <input type="text" name="InpTxt" disabled >文本框0<br> <input type="text" name="InpTxt" disabled >文本框1<br> <input type="text" name="InpTxt" disabled >文本框2<br> </td> </tr> <tr> <td bgcolor="#FFFFFF" align="center" colspan="2"> <input type="submit" value=" 提交" name="B1"></td> </tr> </table> <input type="hidden" name="mm" value="1"> </form> </body>