first, name all the checkboxes the same (say.... "cbox"), then use the below
function with the onclick action

function checkBoxes(theForm){
        var counter = 0;
        for( i=0; i<theForm.cbox.length(); i++ ){
                if( theForm.cbox[i].checked ){
                        counter ++;
                        lastChecked = i;
                }
        }

        if( counter <= 5 ){
                alert("You can only check 5");
                theForm.cbox[lastChecked].checked = false;
        }
}


<input type="checkbox" name="cbox" onclick="checkBoxes(this.form);">
                                                    
Bryan Love ACP
Internet Application Developer
Telecommunication Systems Inc.
[EMAIL PROTECTED]
                                                    


-----Original Message-----
From: Rayna Evans [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 30, 2001 1:01 PM
To: CF-Talk
Subject: javascript form help


does anyone know where i can find a script that will limit the user from
chosing more than a certain amount of choices in a checkbox form?  the user
can only chose up to 5 choices, but there are many choices that they can
chose from.

any help would be greatly appreciated.

Rayna

Rayna Evans
AAMC
2501 M Street, 2nd Fl
Washington, DC 20037
202-862-6243 (direct)
Extension 4243 (internal)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to