0

我正在尝试在具有多个倒数计时器的 Google 应用程序引擎上实现应用程序。

我想知道如何刷新所有计数器

{% for counter in counters %}
    <table class="countdown">
         <tr class="countdown_amount" align="center">
            <td width="25%" valign="bottom" id="day"></td>
            <td width="25%" valign="bottom" id="hour"></td>
            <td width="25%" valign="bottom" id="minute"></td>
            <td width="25%" valign="bottom" id="second"></td>
         </tr>
    </table>

并且有javascript函数来更新<td>

由于有很多事件,截止日期存储在 counter.date 中,我如何将其传递给 javascript?

////////// 我能想到的另一种方法是在 html 中使用 javascript

{% for event in events %}

     var a = parseFloat("{{ event.second }}") * 1000
     var endtime = new Date(a)
     setInterval( function(endtime){
                    var nowtime = new Date()
                    var leftsecond=parseInt((endtime.getTime()-nowtime.getTime())/1000)
                    d=parseInt(leftsecond/3600/24)
                    h=parseInt((leftsecond/3600)%24)
                    m=parseInt((leftsecond/60)%60)
                    s=parseInt(leftsecond%60)
                    document.write('<td width=\"25%\" valign=\"bottom\">' + d + '</td>')
                    document.write('<td width=\"25%\" valign=\"bottom\">' + h + '</td>')
                    document.write('<td width=\"25%\" valign=\"bottom\">' + m + '</td>')
                    document.write('<td width=\"25%\" valign=\"bottom\">' + s + '</td>')}, 1000)

但当然它不起作用,还有其他方法可以在 django 中使用谷歌应用引擎实现多个倒数计时器吗?

谢谢!!

4

0 回答 0