faqts : Computers : Programming : Languages : JavaScript : Tables

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

11 of 22 people (50%) answered Yes
Recently 2 of 10 people (20%) answered Yes

Entry

how can i reference a checkbox in a table cell with javascript?

Aug 25th, 2001 03:25
Juergen Thelen, bryan mcgraw,


This is pretty straightforward, just use the .checked property of the 
checkbox input field of your form that you've placed in the table cell.
Juergen
--- snip ---
<HTML>
<HEAD>
<TITLE>Untitled Document</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT language="JavaScript">
<!--
function ShowIt()
{
  alert(document.myform.checkbox.checked);
}
//-->
</SCRIPT>
</HEAD>
<BODY bgcolor="#FFFFFF" text="#000000">
<TABLE border="1" cellspacing="3" cellpadding="3">
 <TR> 
  <TD valign="top">checkbox in <td></TD>
  <TD> 
   <FORM name="myform" method="post" action="">
    <INPUT type="checkbox" name="checkbox" value="checkbox" checked>
   </FORM>
  </TD>
 </TR>
</TABLE>
<BR>
<BR>
<A href="javascript:ShowIt()">Show checkbox state</A> 
</BODY>
</HTML>
--- snap ---