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!

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.