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:
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);
});
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:
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
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);
}
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!
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