Jump to content

[SOLVED] accessing form fields like an array


jordanwb

Recommended Posts

I have a form with multiple rows of the same data. When the user clicks on a link, it adds a row to the form. Each same field is named like so:

 

<select name="0[type]">
**Options**
</select>
<select name="1[type]">
**Options**
</select>

 

So on and so forth. I try to get the value of the field like so:

 

var value = document.form_name["0[type]"].selectedIndex;

 

But it doesn't work.  When the user clicks "Submit", I use javascript to make sure each field has a value.

 

*Edit*

 

Damn it. I'm an idiot. I was trying to get the selectedIndex of a select that didn't yet exist.  ::)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.