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

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

P: n/a
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!
Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
In article <3f*********************@news.frii.net>, Dom Nicholas
<no********@thanks.com> writes:
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


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
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.