View Full Version : nextSibling problem in a form

08-22-2002, 09:23 PM
Hello i have simple form something like that:
<form name="myFrom">
<td><input type=text name=foo1></td><td>name</td>
<td><input type=text name=foo2></td><td>last name</td>
<td><input type=text name=foo3></td><td>email </td>
now im trying by script to get the innerTEXT from the next <td> after every input
something like :
for(var i=0;i<myFrom.elements.length;i++)
but im getting run time error
what is wrong here?


08-22-2002, 09:33 PM
elements is an array (uses [] syntax), not a method ( () syntax).

Also, the property is innerText, not innerTEXT, and is IE-only. Also, nextSibling is undefined for the form elements, since they are the only child. The td is want is the nextSibling to the parentNode td cell that contains the input.

You could accomplish it according to W3C DOM via:
for(var i = 0; i < myForm.elements.length; i++) {