I want to use a JQuery "check all" function in a form like this: http://jetlogs.org/jquery/jquery_select_all.html
My problem is I am generating my form from a php script, and I don't know exactly how many checkboxes I will have in advance. I use the "array" naming convention to be able to get all the selected checkbox values in my $_POST data... so my checkboxes are like that:
<input type="checkbox" name="items[]" value="<?php echo $id ?>">
but this JQuery declaration does not work:
$("input[@name=items[]]").each(function() { this.checked = checked_status; });
probably because the "[]" at the end of my "items" messes up the JQuery declaration... I tried to write @name=items[] like that: "@name=items[]", and to put some anti-slash before the [ and ] so they're not considered as special characters but it didnt work...
If someone knows a solution and is willing to share it'd be great!! :)
Escape internal brackets with \\
(no space) - it should fix the problem.
This selector works for me:
$('input[name=items\\[\\]]')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With