gpt4 book ai didi

javascript - Django - 倒数计时器

转载 作者:行者123 更新时间:2023-11-28 02:26:19 24 4
gpt4 key购买 nike

嘿,我想实现一个计时器,它会在我转到此模板时启动:

{% block content %}


<h3>C-Test</h3>

<p>In the following text, some of the word endings have been replaced by a gap. The gap is approximately half of the word, e.g. if you see 3 letters, you need to add another 3-4 letters to complete the word. Try your best.</p>

<form action="results" id=results method="POST">
<input type="hidden" name="cTestFormat" value="{{ text }}">

<div class="ctest">
{% csrf_token %}
{{ forms }}{{ ende }}
</div>

<div class="command">
<button type="submit" name="ctest_submit">Submit solution</button>
</div>
</form>


{% endblock %}

如果我单击“提交解决方案”按钮,则结束。

我想将它保存到 POST 请求中,这样我就可以在我的 results.html 中返回时间。

这是我的results.html:

{% block content %}


<h3>C-Test</h3>
{% csrf_token %}
<p>You got {{ richtige }} right!!!!!!</p>
<p>But {{ falsche }} wrong :(</p>

<p> {{ testresult|safe }}</p>


{% endblock %}

我听说您需要一些脚本语言来编写计时器,但我对此没有任何经验。 django 有没有其他方法可以做到这一点,或者我需要像 javascript 这样的东西吗?

最佳答案

这是一个使用 JQuery 的例子

<script type="text/javascript>
var sec = 0;
function pad ( val ) { return val > 9 ? val : "0" + val; }
setInterval( function(){
$("#seconds").html(pad(++sec%60));
$("#minutes").html(pad(parseInt(sec/60,10)));
}, 1000);
</script>

HTML:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<span id="minutes"></span>:<span id="seconds"></span>

关于javascript - Django - 倒数计时器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53821584/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com