I have PHP script that sets checked="checked"
to checkboxes based on the database record. However all, but the first occurence of the checked checkbox are displaying checked. Here is what HTML looks like when it browser parses it:
<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>
And this is what I see in FF26.0
[ ] Not Online
[ ] Facebook
[×] Twitter
What could cause the issue?
Add name
to each of your checkbox fields:
<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>
Its is working fine for me what problem are you having? Here is my fiddle http://jsfiddle.net/dbDj3/
using your code
<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>
It must be some other part of your code that is causing problems
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.