"Embedding" Variables In Other Variables

admin

Administrator
Staff member
Here's the short (well, with me, there's never a _short_; just a long and a super-long...) version of my question. I have a page that creates a series of connected select fields based upon the number of rows the user wants, with the names having a value of the general name plus a number to show the order. In other words, it kind of looks like this:
controllingselectbox1 (changes) dynamicselectbox1
controllingselectbox2 (changes) dynamicselectbox2
And so forth. That way, each controlling select box on the left takes care of which set of values shows up in the dynamic select box. So, for example, one of the categories is ZIP Code, and when you select ZIP Code in the controlling select box, it shows a list of appropriate ZIP codes from which the user may choose over in the other box.

So I've got that setup done without any major problems (well, so far as I know...). My problem, though, comes with the Javascript portion of it. So for the controllingselectbox's select, it calls a JavaScript function on the onChange bit. It passes to the function these two arguments:
- this.form
- rowNum -- This is the iterative number (so the first box, controllingselectbox1, passes 1; the second passes 2; and so on)

What I want to do is have this function do something like this:

if (obj.controllingselectbox***rowNum***.selectedIndex == 1)...

So what I want to do is put the value of rowNum in so that I'm getting a legitimate variable (like, say, obj.controllingselectbox1.selectedIndex).

So basically, is there a nice and relatively simple way to get that done? Or am I going about this in a wholly bad way and there's some really simple way of doing it that I'm missing?

Thanks for any help on this.
 
Top