倒数计时器不能正常工作,只能倒计时到1

时间:2015-09-06 19:17:46

标签: javascript

我制作了一个倒数计时器(简单复制并粘贴)

现在它显示在每一行中,但倒计时仅在某些情况下有效,其他时候它会卡住,而且它没有正常运行

如果我有3600秒的速度,它会比实际速度更快。

示例为here

这里是网络,我知道我想做什么 - here在这个网站上一切正常(不是我的网络)我只是想像这个网站!

点击多个链接,您将了解哪些无效,我无法找到解决方案。

PHP脚本loks:

<?php include('header.php'); ?>

<?php include('menu.php') ?>

<script type="text/javascript" src="wach.js"></script>

<?php

include('config.php');

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

$sql = "SELECT * FROM BitCoint";
$result = mysqli_query($conn, $sql);

if (mysqli_num_rows($result) > 0) {
	?>
<div class="list" id="content-profit">	
<table class="tlist">

<tr>
<td class="id"><b><center>NPK:</center></b></td>
<td class="urlname"><b><center>URL:</center></b></td>
<td class="minreward"><b><center>Min Rewards:</center></b></td>
<td class="time"><b><center>Time(min):</center></b></td>
<td class="description"><b><center>Payouts:</center></b></td>
</tr>

	<?php
    // output data of each row
    while($row = mysqli_fetch_assoc($result)) {
	// echo '<div style="border: 1px solid #e4e4e4; padding: 15px; margin-bottom: 10px;" /> '; ?>

<tr>
<td class="id">

<?php echo $row['id']; ?>

</td>
<td class="urlname">

<a href='<?php echo $row['url']; ?>' onClick="CreateTimer('<?php echo $row['id']; ?>', <?php echo $row['timesec']; ?>)" id="startClock" target="_blank"  ><?php echo $row['urlname']; ?></a>

</td>
<td class="minreward">

<?php echo $row['minreward']; ?>

</td>
<td class="time">

<?php echo $row['timemin']; ?></b><b>
<span id="<?php echo $row['id']; ?>"></span>

</td>
<td class="description">
<font size="1">

<?php echo $row['description']; echo $row['foucentbox1']; echo $row['foucentbox2']; ?>

</font>
</td>
</tr>


</div>
<!--<script type="text/javascript">
window.onload = CreateTimer("<?php echo $row['id']; ?>", "<?php echo $row['timesec']; ?>");</script>

//-->
<?php

	}
	} 
	else {
    echo "0 results";
}

mysqli_close($conn);

?> 
</table></div>

<?php include('footer.php'); ?>

这是我的功能:

window.setTimeout("Tick()", 1000);
var Timer;
var TotalSeconds; 

function CreateTimer(TimerID, Time) {
    Timer = document.getElementById(TimerID);
    TotalSeconds = Time;
    UpdateTimer()
    window.setTimeout("Tick()", 1000);

}

function Tick() {
    if (TotalSeconds <= 0) {
        alert("Lets Go One More Time")
        return;
    }
    TotalSeconds -= 1;
    UpdateTimer()
    window.setTimeout("Tick()", 1000);
}

function UpdateTimer() {
    var Seconds = TotalSeconds;
    var Days = Math.floor(Seconds / 86400);
    Seconds -= Days * 86400;
    var Hours = Math.floor(Seconds / 3600);
    Seconds -= Hours * (3600);
    var Minutes = Math.floor(Seconds / 60);
    Seconds -= Minutes * (60);
    var TimeStr = ((Days > 0) ? Days + " days " : "") + LeadingZero(Hours) + ":" + LeadingZero(Minutes) + ":" + LeadingZero(Seconds)
    Timer.innerHTML = TimeStr;
}


function LeadingZero(Time) {
    return (Time < 10) ? "0" + Time : + Time;
}

function Click(){
    alert("hello")
}

0 个答案:

没有答案