If you really need those brackets, just escape them with two
backslashes:

$('input[name=foo\\[\\]]:checked').length


If you need them as a post query, just use :
var $foos = $('input[name=foo\\[\\]]:checked');
var postQuery = $.param($foos);


On Mar 2, 6:08 am, mklebel <mkle...@gmail.com> wrote:
> Been losing my hair on this.
> I'm trying to assign my checkbox array to a variable that I can send
> through a post. But I the variable 'tempy' is always undefined. I must
> be confused on how to reference an array, or maybe there is a better
> way to do this?
>
> js:
> var tempy = $('input[name=foo]:checked').val();
>
> html:
> <input type="checkbox" name="foo[]" value="klaybul1" />
> <input type="checkbox" name="foo[]" value="klaybul2" />
> <input type="checkbox" name="foo[]" value="klaybul3" />
>
> Thanks in advance!

Reply via email to