页面重新加载时保存选中的复选框
问题描述:
对于我的搜索引擎,我使用带有复选框的表单设计了一个过滤器。提交这些文件时,过滤器功能可以正常工作(为此使用Flask)。显示结果时,将再次取消选中用作过滤器的复选框。我是否需要将信息保存在localStorage中,该怎么做?
感谢您的帮助< 3
For my search-engine I designed a filter using a form with checkboxes. When submitting those, the filter function works fine (using Flask for this). Yet the checkboxes which where used as a filter are unchecked again when the results are shown. Do I need to save the information in the localStorage, and how can this be done? Thanks for your help <3
这是我的复选框代码的一部分(我是HTML / JS的新手):
This is a part of my Code for the checkbox (I am a newbie to HTML/JS):
<form>
<article class="card-group-item">
<header class="card-header">
<span class="title">Document Types </span>
</header>
<div class="filter-content">
<div class="card-body">
<label class="form-check" >
<input class="form-check-input" type="checkbox" name="doctype" value="offer" id="offer">
<span class="form-check-label">Offer</span>
</label> <!-- form-check.// -->
<button type="submit" class="btn btn-secondary btn-sm">Submit</button>
</div> <!-- card-body.// -->
</div>
</article> <!-- card-group-item.// -->
</form>
答
在复选框中使用已选中,并在此处
Use checked in your checkbox and read here
<form>
<article class="card-group-item">
<header class="card-header">
<span class="title">Document Types </span>
</header>
<div class="filter-content">
<div class="card-body">
<label class="form-check" >
<input class="form-check-input" type="checkbox" name="doctype" value="offer" id="offer" checked>
<span class="form-check-label">Offer</span>
</label> <!-- form-check.// -->
<button type="submit" class="btn btn-secondary btn-sm">Submit</button>
</div> <!-- card-body.// -->
</div>
</article> <!-- card-group-item.// -->
</form>