You don't need to escape them,

$('input:checkbox[name=foo[]]:checked').serialize()

works as well. If you want the brackets instead of %5B%5D just use
unescape:
unescape($('input:checkbox[name=foo[]]:checked').serialize());

Either way it's ugly ;)

On Mar 3, 6:47 am, dabear <bjorni...@gmail.com> wrote:
> 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