faqts : Computers : Programming : Languages : JavaScript : Forms : Checkboxes

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

14 of 37 people (38%) answered Yes
Recently 3 of 10 people (30%) answered Yes


how can i get a string which is composed by the checked checkbox's values?
How can i get a string which is composed of the values of the checkboxes checked?

Feb 20th, 2002 06:51
Juergen Thelen, Junssun Lin,

Pretty straightforward, just use the .checked property of the 
checkbox input field of your form...
--- snip ---
<TITLE>Untitled Document</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<SCRIPT language="JavaScript">
function ShowIt()
  var s = document.myform.checkbox.checked ? "checked" : "unchecked";
<BODY bgcolor="#FFFFFF" text="#000000">
  <FORM name="myform" method="post" action="">
    <INPUT type="checkbox" name="checkbox" value="checkbox" checked>
<A href="javascript:ShowIt()">Show checkbox state as string</A> 
--- snap ---