【发布时间】:2021-01-01 03:53:36
【问题描述】:
我知道我们可以使用 URL 在 HTML 表单中预先填写一些数据。 例如www.example.com/?itemname=sth
我可以知道是否有类似的方法可以通过 URL 预先选中复选框?
<ul class="list-group">
<li class="list-group-item">
<div class="form-check">
<label class="form-check-label">
<input type="checkbox" class="form-check-input product_check" id="Tutor_subject_1" name="Maths" value="Maths"
<?php if (isset($_GET['itemname']) && $_GET['itemname'] === 'sth' ): ?>
document.getElementByName("Maths").click();
<?php endif; ?>>Maths<br>
</label>
</div>
</li>
</ul>
谢谢@jrswgtr。我还有一个后续问题。上面的设置其实就是我的结果页的过滤器。您的解决方案是可行的,但它只是选中了该框,但没有像通常那样将所选项目的值传递给我的 SQL。请问怎么改?
【问题讨论】: