Jump to content

Need help getting data from multidimensional array form data


simpjd

Recommended Posts

So I have the following HTML code:

 

<form name="form">

<input type="text" name="txt[0][0]" value="TEST MESSAGE1" />

<input type="text" name="txt[0][1]" value="TEST MESSAGE2" />

<input type="text" name="txt[0][2]" value="TEST MESSAGE3" />

 

<input type="text" name="txt[1][0]" value="TEST MESSAGE4" />

<input type="text" name="txt[1][1]" value="TEST MESSAGE5" />

<input type="text" name="txt[1][2]" value="TEST MESSAGE6" />

</form>

 

 

The array “txt” can contatin any number of arrays but each nested array is always 0,1,2.

 

 

I need to write a bit of code to extract all the values.

 

 

I have so far:

 

 

 

var txt = document.form["txt[][]"].length;

 

for (var c=0; c < txt; c++){

document.write(document.form["txt[“+c+”][0]"].value);

document.write(document.form["txt[“+c+”][1]"].value);

document.write(document.form["txt[“+c+”][2]"].value);

}

 

 

I would really appreciate any help!

 

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.