多试几次下面的代码,看一下结果。alert(payBeginTime);

解决方案 »

  1.   

    你这样试一下 
    <script language="javascript">
    var payBeginTime = 2 ;payBeginTime=parseInt(payBeginTime,10)-1; 
    alert(payBeginTime); payBeginTime=parseInt(payBeginTime,10)-1; 
    alert(payBeginTime); payBeginTime=parseInt(payBeginTime,10)-1; 
    alert(payBeginTime); </script>
      

  2.   


    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title></title>
     
    <script> var payBeginTime=0;
    function testPay()
    {
    payBeginTime='20';
    showPayTime();
    timedCount();
    }function timedCount()
    {  
       payBeginTime=parseInt(payBeginTime,10)-1;
       alert(payBeginTime);
    if(payBeginTime<0)
    {
    alert("成功了!!!!!!!");
    }
    else
    {
       showPayTime();
        }   
       
       if(payBeginTime>0){
     
        t=setTimeout("timedCount()",1000);
       
       }
    }
    //页面显示时间倒计时
    function showPayTime()
    {
    var second="0";
    var minute="0";
    minute=parseInt(payBeginTime/60,10);
    second = payBeginTime%60;
       
    if(minute==0)
     {
      document.getElementById('payConvertTime').innerText=second;
     }
     else
     {
      document.getElementById('payConvertTime').innerText=minute+"分"+second;
     }
    }
                   
    </script></head>
    <body>
    <tr>
      <div>正在准备……剩余时间:<font color="#FF6600"><label id="payConvertTime">0&nbsp;</label></font>秒</div>
                     
    <div><input type="button" name="bt" onclick="testPay()" value="测试"/></div>
    </body>
    </html>这是那个源代码,帮忙看看,
    小弟谢谢了呀!如果把timedCount()里的 payBeginTime=parseInt(payBeginTime,10)-1;换成 payBeginTime=parseInt(payBeginTime,10)-6;就可以alert("成功了!!!!!");
      

  3.   

    if(payBeginTime>0)等于0时就不会执行 t=setTimeout("timedCount()",1000);