Accessing Variables in Javascript using .length

Posted by CoV on Stack Overflow See other posts from Stack Overflow or by CoV
Published on 2010-06-10T22:32:05Z Indexed on 2010/06/10 22:42 UTC
Read the original article Hit count: 163

Filed under:
|

Hey all,

I'm pretty new to Javascript, so forgive me if this is a simple question.

I'm trying to access the length of a set of checkboxes in a form using Javascript. However, I need to be able to change the "name" field of the checkboxes to check several different sets of them. Right now, my sample code looks like:

var set = "set" + x;
totalLength = optionBoxes.set.length;

The variable x is being incremented by a for loop that wraps the whole thing and the name of the checkbox sets that I'm trying to access are set0, set1, set2, etc.

Thanks.

Edit: small typo fixes

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about variables