Flask 在页面重新刷新后保留复选框
我使用了我尝试使用Java脚本的烧瓶模板的代码
<div class="rows">
<h3>In oven</h3>
{% for checkbox in checkboxes: %}
<li><input type="checkbox"></li>
{% endfor %}
</div>
,但是在刷新复选框后,即使我以前检查过它也是如此。我想检查一下,然后将页面刷新后,以保持支票。有什么想法如何做?
I have this piece of code of a flask template
<div class="rows">
<h3>In oven</h3>
{% for checkbox in checkboxes: %}
<li><input type="checkbox"></li>
{% endfor %}
</div>
I tried using java script but after refresh the checkboxes resets even if I checked it before. I want to checked it and after refreshing the page the check to stay. Any ideas how to do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要将复选框的值存储在某处,以便在再次加载页面时对其进行设置。
该值必须是可以评估为 true/false 的值。
检索值后,您需要评估是否在输入中添加选中的属性。
在此示例中,我在视图上使用变量。
当然,对于更完整的问题,这可以更具体
You need to store somewhere the value of the checkbox to set it when loading the page again.
This value has to be something that can be evaluated as true/false.
After retrieving the value you need to evaluate for add or not the checked property in the input.
In this example, I'm using a variable on the view.
Of course, with a more complete question this can be more specific