日期:2014-05-20  浏览次数:20428 次

在线等,时间按钮
注册的时候,有一个 "确定 "按钮,要等到10秒过后才能点击,是按照10、9、8、7、6、5…………秒显示的,请问怎么实现呢?

------解决方案--------------------
送你个例子(其中按钮换成服务器端控件也是可以一样的效果)

<input type= "button " id= "rulesubmit " value= "同意 " /> <br />
<script type= "text/javascript ">
var secs = 9;
var wait = secs * 1000;
document.getElementById( "rulesubmit ").value = "同 意( " + secs + ") ";
document.getElementById( "rulesubmit ").disabled = true;
for(i = 1; i <= secs; i++) {
window.setTimeout( "update( " + i + ") ", i * 1000);
}
window.setTimeout( "timer() ", wait);
function update(num, value) {
if(num == (wait/1000)) {
document.getElementById( "rulesubmit ").value = "同 意 ";
} else {
printnr = (wait / 1000) - num;
document.getElementById( "rulesubmit ").value = "同 意( " + printnr + ") ";
}
}
function timer() {
document.getElementById( "rulesubmit ").disabled = false;
document.getElementById( "rulesubmit ").value = "同 意 ";
}
</script>