[jQuery] IDs of all checked checkboxes

2007-01-11 Thread Mungbeans
I have a form with multiple checkboxes, each with their own unique id. How do I go about returning the ids of the selected checkboxes into an array? Sorry if this is a bit basic, but it has me stumped. -- View this message in context:

Re: [jQuery] IDs of all checked checkboxes

2007-01-11 Thread Mike Alsup
I have a form with multiple checkboxes, each with their own unique id. How do I go about returning the ids of the selected checkboxes into an array? This should do it: var a[]; $(':checkbox').each(function() { if (this.id) a.push(this.id); });

Re: [jQuery] IDs of all checked checkboxes

2007-01-11 Thread Mungbeans
malsup wrote: var a[]; $(':checkbox').each(function() { if (this.id) a.push(this.id); }); I get this error: missing ; before statement var a[]; (curse my rudimentary javascript skills!) -- View this message in context:

Re: [jQuery] IDs of all checked checkboxes

2007-01-11 Thread Erik Beeson
You want: var a = []; You've been doing too much C and Java :) --Erik On 1/11/07, Michael Geary [EMAIL PROTECTED] wrote: var a[]; $(':checkbox').each(function() { if (this.id) a.push(this.id); }); I get this error: missing ; before statement var a[]; (curse my

Re: [jQuery] IDs of all checked checkboxes

2007-01-11 Thread Mungbeans
Erik Beeson wrote: You want: var a = []; You've been doing too much C and Java :) I found this works too: a = new Array() $(':checkbox').each(function() { if (this.checked) { if (this.id) a.push(this.id); }

Re: [jQuery] IDs of all checked checkboxes

2007-01-11 Thread limodou
a = new Array() $(':checkbox').each(function() { if (this.checked) { if (this.id) a.push(this.id); } }); a = [] equals a = new Array() but 'var' is used to limited the variable scope. -- I like python!

Re: [jQuery] IDs of all checked checkboxes

2007-01-11 Thread Michael Geary
var a[]; $(':checkbox').each(function() { if (this.id) a.push(this.id); }); I get this error: missing ; before statement var a[]; (curse my rudimentary javascript skills!) OK... It says there is a missing ; before the statement var a[];. What is before the