MattsBits
MattsBits - Brunel District

MattsBits

MattsBits RSS Feed - Subscribe Now!

11/06/2009 : Yes No Checkboxes With Automatic Uncheck

Categories : | JavaScript | Views : 563 | Email Link Print

The following article explains how to create sets of Yes No checkboxes that are mutually exclusive. That is when you check the Yes box the corresponding No box is unchecked.

The HTML below shows how this can be achieved :

<html>
<head><title></title></head>
<body>

<script language="JavaScript">
<!-- Begin
function CheckBoxesByName(sName,sMode)
{


At this point you need to insert the CheckBoxesByName function definition from the Check, Uncheck And Toggle Checkboxes By Name page

}
//  End -->
</script>

<p>
Yes<input type="checkbox" checked="yes" name="cbox_yes_1"
      onchange="CheckBoxesByName('cbox_no_1',2)">
No<input type="checkbox" name="cbox_no_1"
     onchange="CheckBoxesByName('cbox_yes_1',2)"></p>

<p>
Yes<input type="checkbox" checked="yes" name="cbox_yes_2"
      onchange="CheckBoxesByName('cbox_no_2',2)">

No<input type="checkbox" name="cbox_no_2"
     onchange="CheckBoxesByName('cbox_yes_2',2)"></p>

<p>
Yes<input type="checkbox" checked="yes" name="cbox_yes_3"
      onchange="CheckBoxesByName('cbox_no_3',2)">
No<input type="checkbox" name="cbox_no_3"
     onchange="CheckBoxesByName('cbox_yes_3',2)"></p>

</body>
</html>


If you want to see the script in action then click the example file below.

Technorati Tags : | javascript |

Author : Matt Hawkins  Last Edited By : Matt Hawkins  Permalink : Yes No Checkboxes With Automatic Uncheck
 
 
 
PHP Powered  MySQL Powered  Valid XHTML 1.0  Valid CSS  Firefox - Take Back The Web  EUKHost - Recommended Webhosting Solutions

MattHawkins CMS v2.0 - Copyright 2009-2010