<html>
<head>
<title></title>
<script language=javascript> 
var lefttime = 100
var tid function b()
{
   lefttime = 100
}function x() 
{   lefttime-- 
  document.all.xx.innerText ="倒时计:"+lefttime 

tid = window.setInterval("x()",1000) 
</script> </head>
<body>
<table class=tb> 
<tr> 
<td id=xx></td> 
</tr> 
<input type=button onclick="b()" value="button">
</table>
</html>

解决方案 »

  1.   

    <html>
    <head>
    <title></title>
    <script language=javascript> 
    var lefttime = 100
    var tid function b()
    {
       lefttime = 100
    }function x() 
    {   lefttime-- 
      document.all.xx.innerText ="倒时计:"+lefttime 
      if(lefttime==0) {clearInterval(tid)}

    tid = window.setInterval("x()",1000) 
    </script> </head>
    <body>
    <table class=tb> 
    <tr> 
    <td id=xx></td> 
    </tr> 
    <input type=button onclick="b()" value="button">
    </table>
    </html>
      

  2.   

    <html><body>
    <div id="count">
    </div>
    <input type="button" value="start" onclick="starts();">
    <input type="button" value="stop" onclick="stops();">
    </body></html>
    <script language="javascript"> 
    i=100;
    function goo(){
    if(i<=0) return ; 
    document.getElementById("count").innerHTML = i--;
    setTimeout("goo();", 1000);
    }
    function starts(){ 
    i = 100;
    goo(); 
    }
    function stops(){ 
    i=0;
    }
    </script>
      

  3.   

    若input 类型换成"submit" ,是否影响其它数据提交?