English 中文(简体)
无法解析 Javascrip 记时器
原标题:Can t solve Javascript Timer

我的计时器在这个页面上"http://jian.comoj.com/countdown.php" rel=“nofollow”>http://jian.comoj.com/countdown.php 没有倒计时。我在这样做时遵循了视频辅导,但不知何故有些不对劲,我不知道是什么。

<?php
include "connect.php";
$query= "select * from product where product_id= 1 ";
$result= mysql_query($query);
$record= mysql_fetch_object($result);
$time= $record->end_time;
date_default_timezone_set( Asia/Singapore );
$unix_time= strtotime($time);

? & gt;

<script type="text/javascript">

    function countdown(){

        <?php 
            $now= time();

            $sec= $unix_time-$now;

            $min= $sec/60;

            $hour= $min/60;

            $sec %= 60;

            $min %= 60;
            ? & gt;

        var hour= <?php echo floor($hour); ? & gt;;
        var min= <?php echo $min; ? & gt;;
        var sec= <?php echo $sec; ? & gt;;
        document.getElementById("hour").innerHTML = hour;
        document.getElementById("min").innerHTML = min;
        document.getElementById("sec").innerHTML = sec;
        setInterval( countdown() ,1000);
    }

</script>

<div id="hour"></div>
<div id="min"></div>
<div id="sec"></div>

<script type="text/javascript">countdown();</script>
问题回答
function countdown(){

        var hour= 3;
        var min= 39;
        var sec= 58;
        document.getElementById("hour").innerHTML = hour;
        document.getElementById("min").innerHTML = min;
        document.getElementById("sec").innerHTML = sec;
        setTimeout( countdown() ,1000);
    }

看看他们的功能是固定的, 即小时,分钟和秒。





相关问题
countDownTimer isn t working, why?

I have a service B that sends a specific number of messages in a fixed interval. this service is called from another service A. the code used in service A is @Override public void onStart (Intent ...

Android CountDownTimer

When writing : CountDownTimer timer = new CountDownTimer(1000, 100) { @Override public void onTick(long l) { } @Override public void onFinish() {...

Timer in Android not updating

I have a timer in android to countdown to a future date, but it is not refreshing. Any help appreciated. my code is posted below: public class Activity1 extends Activity { /** Called when the ...

Countdown 10 min, run a .php file, then restart

My question is a simple yet I cannot find a way around it. I need a server time countdown script to run for 10 minutes, run a php file and when the countdown ends restart again. I have read the jQuery ...

热门标签