繁体   English   中英

复选框未显示为已选中状态,即使显示为已选中

[英]Checkbox is not displaying as checked, even though it is

我有一个PHP脚本,它根据数据库记录将checked="checked"为复选框。 但是,除了第一次出现的所有复选框,都显示为已选中。 这是HTML浏览器对其进行解析时的外观:

<input type="checkbox" id="not_online"><label for="not_online">Not Online</label>
<input type="checkbox" id="facebook" checked="checked"><label for="facebook">Facebook</label>
<input type="checkbox" id="twitter" checked="checked"><label for="twitter">Twitter</label>

这就是我在FF26.0中看到的

[ ] Not Online
[ ] Facebook
[×] Twitter

是什么原因引起的?

为每个复选框字段添加name

<input type="checkbox" id="not_online" name="not_online"><label for="not_online">Not Online</label>
<input type="checkbox" id="facebook" name="facebook" checked="checked"><label for="facebook">Facebook</label>
<input type="checkbox" id="twitter" name="twitter" checked="checked"><label for="twitter">Twitter</label>

它对我来说很好,您有什么问题? 这是我的小提琴http://jsfiddle.net/dbDj3/

使用您的代码

    <input type="checkbox" id="not_online"><label for="not_online">Not Online</label>
    <input type="checkbox" id="facebook" checked="checked"><label for="facebook">Facebook</label>
    <input type="checkbox" id="twitter" checked="checked"><label for="twitter">Twitter</label>

一定是导致问题的代码的其他部分

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM