<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>按钮倒计时</title>
<script language="javascript">
var timer = 15;//计数器
function btnShow()
{
document.getElementById("btnSubmit").disabled = true;
str = "倒计时...";
timer--;
if(timer <= 0)
{
document.getElementById("btnSubmit").value = "提交";
document.getElementById("btnSubmit").disabled = false;
}
else
{
document.getElementById("btnSubmit").value = str + timer +"秒";
}
}
function started(){
if(timer > 0){
window.setInterval(btnShow,1000);
}else{
clearInterval(timer);
timer = 15;
}
}
</script>
</head>
<body>
<form >
<p>
<label><input type="button" name="btnSubmit" id="btnSubmit" value="提交" οnclick="started();" />
</label>
</p>
</form>
</body>
</html>