simpjd Posted May 11, 2009 Share Posted May 11, 2009 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! Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted May 11, 2009 Share Posted May 11, 2009 Is there a reason to set the name attribute as a multi-dimensional array? Quote Link to comment Share on other sites More sharing options...
simpjd Posted May 11, 2009 Author Share Posted May 11, 2009 The name needs to be as it is for later reasons when this data is processed via php. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.