Connecting Tech Pros Worldwide Help | Site Map

how do I access value of text field inside a table cell

Dom Nicholas
Guest
 
Posts: n/a
#1: Jul 20 '05
Hi,

I have a table (inside a form) that is dynamically created ie the user
can add / remove rows dynamically. Each table row has 4 columns :

a selection pull down list
a text field for entering an amount
a check box
a button

Note that the cell's and rows does not have a meaningful NAME tags ( the
value is simply an incremented value each time a row is created ).

When the user submits the form, I want to verify the supplied values. I
want to loop over the each row and inspect the rows' cells contents.

So for each row, I want to:

- find out what was selected in the pulldown list
- look at the amount given in the text field
- see if the check box is

How do I do this ? I can get to a cell, thetable.rows[0].cells[1] for
example, but then I'm lost. I don't want to use innerHTML if possible.
There must be a way to access the cell's content, access its assigned
object and then get its value. I've seen firstChild.nodeType been used
in places but (a) can't make sense of it cos I'm a novice at the DOM,
and (b)have not been able to find what the nodeType's are , for example,
what is type 3 and where can I find a reference of possible values/types
?

ok thanks very much for any help on this.
-Dom


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
HikksNotAtHome
Guest
 
Posts: n/a
#2: Jul 20 '05

re: how do I access value of text field inside a table cell


In article <3f84874f$0$195$75868355@news.frii.net>, Dom Nicholas
<nospam2001@thanks.com> writes:
[color=blue]
>Hi,
>
>I have a table (inside a form) that is dynamically created ie the user
>can add / remove rows dynamically. Each table row has 4 columns :
>
> a selection pull down list
> a text field for entering an amount
> a check box
> a button[/color]

You should be able to loop through the forms collection, check the type of
field, and then act accordingly.

for (i=0;i<document.forms[0].elements.length;i++){
if (document.forms[0].elements[i].type = "select"){

}
//etc.....
}
--
Randy
Closed Thread