Fallen_angel Posted November 25, 2006 Share Posted November 25, 2006 how can I limit the number of selected boxes to 2 in a form like the one bellow [code]<form><tr><td><INPUT TYPE=CHECKBOX NAME="taste_type[]" onclick="boxchk(this,3)" VALUE="Berry">Berry</td> <td><INPUT TYPE=CHECKBOX NAME="taste_type[]" VALUE="Bubblegum">Bubblegum</td> <td><INPUT TYPE=CHECKBOX NAME="taste_type[]"VALUE="Chemical">Chemical</td> <td><INPUT TYPE=CHECKBOX NAME="taste_type[]" VALUE="Citrus">Citrus</td> <td><INPUT TYPE=CHECKBOX NAME="taste_type[]" VALUE="Chocolate" >Chocolate</td></tr></form>[/code] Link to comment https://forums.phpfreaks.com/topic/28423-limit-checkbox-array-in-form/ Share on other sites More sharing options...
printf Posted November 25, 2006 Share Posted November 25, 2006 If you want to do it in real time in the form, then JavaScript is the only way. If you want to do it with PHP, then handle it when the form is submitted, if more than 2 are selected, return the form with a explanation of the error so they can correct it.printf Link to comment https://forums.phpfreaks.com/topic/28423-limit-checkbox-array-in-form/#findComment-130072 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.