| View previous topic :: View next topic |
| Author |
Message |
saurabh New member

Joined: 01 Oct 2002 Posts: 4
|
Posted: Tue Oct 01, 2002 2:57 pm Post subject: Looping through form fields |
|
|
Hi everyone! I have a javascript question and will really appreciate any help.
I have a html form which has 10 different text boxes along with other form elements. These text boxes are named amount1, amount2... amount10. What I want to know is if there is a way I can loop through the values entered in these text boxes when I click the submit button to call the javascript function.
Thanks. |
|
| Back to top |
|
 |
mgm Site Admin

Joined: 13 Jul 2002 Posts: 304 Location: Salt Lake City, UT
|
Posted: Wed Oct 02, 2002 12:13 am Post subject: |
|
|
This should work: | Code: | for (i=1; i<=10; i++) {
textname = "amount" + i;
val = document.formname[textname].value;
alert(val);
} |
Replace the alert with whatever you actually plan to do with the values. _________________ Michael Moncur
Owner and Moderator, The JavaScript Workshop
Read the guidelines before posting: http://www.jsworkshop.com/posting.html |
|
| Back to top |
|
 |
|