Client side

<html>
<head>
<title>Untitled</title>
<SCRIPT LANGUAGE="_javascript_" TYPE="text/_javascript_">
<!--
function checkMax(obj,thisform){
  var cnt = 0;
  if(obj.checked){
   for(var i=0;i<thisform.myCheckbox.length;i++){
    if(thisform.myCheckbox[i].checked){
     if(++cnt>3){
      obj.checked = false;
      return false;
     }
    }
   }
  }
  return true;
}
//-->
</SCRIPT>
</head>

<body><cfoutput>
<form action=""> <cfloop from="1" to="10" index="i">
<input type="checkbox" name="myCheckbox" value="#i#" > checkMax(this,this.form);"> option #i#<br>
</cfloop>
</form></cfoutput>
</body>
</html>

ServerSide

<cfif ListLen(form.myCheckbox) GT 3>
<!--- error treatment --->

-----Original Message-----
From: Ketan Patel [mailto:[EMAIL PROTECTED]
Sent: donderdag 11 december 2003 16:52
To: CF-Talk
Subject: Limit checkbox selection using CF & JS

Hi,
Does anybody have any JS or CFscript which will limit selection of
checkboxes from the  dynamic created form. I have a form which has some
checkboxes created dynamically depending upn the query results. I want
to
limit selection to 3 only .

Thanks in advance.

Ketan Patel
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to