Limit Amount of CHeckbox Selections
Hi Ray,
In the multiple add to cart, my client is asking that I limit the amount of selections to no more than three. Is this possible?
Hi Ray,
In the multiple add to cart, my client is asking that I limit the amount of selections to no more than three. Is this possible?
There is Javascript code online that goes like this:
Checkbox code:
<input name="ATCCheck[]" id="ATCCheck[]" type="checkbox" value="<?php echo $row_WADAcounsellors['counsellorID']; ?>" onclick="setChecks(this)" />
Javascript:
<script type="text/javascript">
<!--
//initial checkCount of zero
var checkCount=0
//maximum number of allowed checked boxes
var maxChecks=3
function setChecks(obj){
//increment/decrement checkCount
if(obj.checked){
checkCount=checkCount+1
}else{
checkCount=checkCount-1
}
//if they checked a 4th box, uncheck the box, then decrement checkcount and pop alert
if (checkCount>maxChecks){
obj.checked=false
checkCount=checkCount-1
alert('you may only choose up to '+maxChecks+' options')
}
}
//-->
</script>
Did you get this working with your function? This looks like it may be a handy piece of code for others if it works for you.
Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.
These out-of-the-box solutions provide you proven, tested applications that can be up and running now. Build a store, a gallery, or a web-based email solution.