File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes editing document.form.value field name Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "editing document.form.value field name" Watch "editing document.form.value field name" New topic

editing document.form.value field name

AnilPrakash Raju
Ranch Hand

Joined: Jul 26, 2004
Posts: 137
in my jsp page, i allow the user to add items to a list and the list is displayed on the same page. The field name of the new item is incremented by 1.
for example
for item 1 - field name is 'level0'
for item 2 - field name is 'level1'
for item 3 - field name is 'level2'

I using this way to save the values later in an array.

But my question is that:
I need to check the value of the field in javascript.
I am sending the length of the array to my javascript function but how to i get the value of the field.

What i am doing in js:
for (var x = 0; x < length; x++)
var fieldValue =document.form2.level'+x+'.value;

But this does not work.

Does anyone has any suggestions how i can read the value of the fields?

Thanks in advance

Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63837

Well, of course that won't work.

You need to use the alternative fetch notation:

When posting code, please use UBB code tags as I have done.

[Asking smart questions] [About Bear] [Books by Bear]
AnilPrakash Raju
Ranch Hand

Joined: Jul 26, 2004
Posts: 137

I agree. Here's the link:
subject: editing document.form.value field name
It's not a secret anymore!