By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,238 Members | 1,459 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,238 IT Pros & Developers. It's quick & easy.

getting field value into array

P: 59
hi

consider the following html
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>Untitled Document</title>
  6.  
  7.     <link rel="stylesheet" type="text/css" href="styles.css" />
  8. </head>
  9. <form onsubmit="return validate();" action="index.html" method="post" name="myform">
  10. <input name="test[]" type="text" value="1" />
  11. <input name="test[]" type="text" value="2" />
  12. <input name="test[]" type="text" value="3" />
  13. <input name="test[]" type="text" value="4" />
  14. <input name="test[]" type="text" value="5" />
  15. <input name="test[]" type="text" value="6" />
  16. <input name="test[]" type="text" value="7" />
  17. <input name="submit" type="submit" />
  18. </form>
  19. <body>
  20. </body>
  21. </html>
I also created array var test = new Array();

How can I get the values of text fields into this array?
Dec 10 '08 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
Expand|Select|Wrap|Line Numbers
  1. var test = document.getElementsByName("test[]");
Dec 10 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.