Click to See Complete Forum and Search --> : Referring to a table element


rogers
11-04-2003, 11:21 AM
Hello,

In javascript, how do I refer to the 'in_newtask' element in the form below? Please note that this element is inside a table.

Thanks

<FORM ACTION="emp" METHOD="POST" name=add_tasks_form>
<table id="tasktable1" align="left" cellspacing="0" cellpadding="2" border="0">
<TR>
<td><left>Enter New Task:</left></td>
<TD><INPUT TYPE="text" NAME="in_newtask" SIZE="50" MAXLENGTH="50"></TD>
</TR>
<BR>
<BR>
</table>
<BR>
<BR>
<table id="tasktable2" align="center" cellspacing="0" cellpadding="2" border="0">
<tr><td><right>Current Tasks:</right></td></tr>
<TR>
<td>
<SELECT name=in_tasklist multiple readonly size=10>
<OPTION VALUE="33">AAA
<OPTION VALUE="31">BBB
</SELECT>
</td>
</TR>
</table>
<BR>
<BR>
<div align="center">
<td><INPUT TYPE="button" VALUE="Add" onClick=ConfirmAction()></td>
<INPUT TYPE="submit" NAME="Action" VALUE="Delete">
</div>
</FORM>

requestcode
11-04-2003, 11:48 AM
document.add_tasks_form.in_newtask.value="yes"

would place the value "yes" in the text box.

rogers
11-04-2003, 11:51 AM
Would that work for reading the value from that field ?

I don't need to use the table name that this field is in?

Thanks

requestcode
11-04-2003, 11:53 AM
You don't need to reference the table element to get the value from the form element. To do that you could do this":

myvalue=document.add_tasks_form.in_newtask.value

The variable "myvalue" would now contain the value from the form element.