Dave,

Here is a page of HTML that uses JavaScript to loop through all of the
elements of a form and set the checked value to true or false.  I am not
sure how to specify that it only look at checkboxes, but since checked is
only a property of checkboxes (I think), the browser would just ignore an
attempt to change the checked property of other types of controls.  You
could also explicitly state which boxes to uncheck:

        document.myForm.cb2.checked = false;

Hope this helps.

Matthieu


<html>

<head>
<title>New Page 1</title>
<script language="JavaScript">
function inspectBox() {
        if (document.forms[0].checkThis.checked) {
                alert("The box is checked.");
        } else {
                alert("The box is not checked at the moment.");
        }
}

function checkAll() {
        for (var i in document.myForm) {
                document.myForm.elements[i].checked = true;
        }
}

function uncheckAll() {
        for (var i in document.myForm) {
                document.myForm.elements[i].checked = false;
        }
}
</script>
</head>
<body>

<form name="myForm">
        <input type="checkbox" name="cb1">Check Box 1<BR>
        <input type="checkbox" name="cb2">Check Box 2<BR>
        <input type="checkbox" name="cb3">Check Box 2<BR>
        <input type="button" value="Check All" onClick="checkAll()">
        <input type="button" value="Uncheck All" onClick="uncheckAll()">
</form>

</body>
</html>

> -----Original Message-----
> From: Bosky, Dave [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, January 09, 2001 3:08 PM
> To: CF-Talk
> Subject: checking multiple boxes w/single button?
> 
> 
> 
> I have a form containing a dynamic list of checkboxes that 
> are used to delete messages.  I already have a button that 
> will delete all checked mail but my question is how do I 
> make a button that will automatically put a check in each box?
> <!-----
> <form name="msglist" action="" method="">
>       <cfoutput query= "msgs">
>       <input type="checkbox" name="MsgsToDelete" 
> value="#MessageNumber#">
>       </cfoutput>
> <input type="button" value="CheckMail" onClick="checkAll();">
> <form>
> ---->
> 
> 
> 
> 
> 
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to