?
Solved

Forms Unlimited ?

Posted on 1998-06-29
2
Medium Priority
?
154 Views
Last Modified: 2011-09-20
Is it possible to set a maximum number of checkboxes checked in a form ?

I have 10 answers but i don't want the user to check more than 4 ! there should be some kind of alert " you cannot check more than 4 boxes" or something like that !
is that possible ? if so .. HOW ??
thanks ...
0
Comment
Question by:BlackSun
2 Comments
 

Author Comment

by:BlackSun
ID: 1844435
Edited text of question
0
 
LVL 28

Accepted Solution

by:
sybe earned 240 total points
ID: 1844436
<script>
var BoxesChecked = 0;
function CheckTotalNumber(name) {
      if (BoxesChecked < 4 && name.checked) {
            BoxesChecked = BoxesChecked + 1;
      } else if (name.checked) {
            alert("You can only check 4 items");
            name.checked = false;
      } else if (!name.checked) {
            BoxesChecked = BoxesChecked - 1;
      }
}
</script>



<form>
<INPUT type=checkbox name="checkbox1" onClick="CheckTotalNumber(this)"> checkbox1
<br>
<INPUT type=checkbox name="checkbox2" onClick="CheckTotalNumber(this)"> checkbox2
<br>
<INPUT type=checkbox name="checkbox3" onClick="CheckTotalNumber(this)"> checkbox3
<br>
<INPUT type=checkbox name="checkbox4" onClick="CheckTotalNumber(this)"> checkbox4
<br>
<INPUT type=checkbox name="checkbox5" onClick="CheckTotalNumber(this)"> checkbox5
<br>
<INPUT type=checkbox name="checkbox6" onClick="CheckTotalNumber(this)"> checkbox6
<br>
<INPUT type=checkbox name="checkbox7" onClick="CheckTotalNumber(this)"> checkbox7
<br>
<INPUT type=checkbox name="checkbox8" onClick="CheckTotalNumber(this)"> checkbox8
<br>
<INPUT type=checkbox name="checkbox9" onClick="CheckTotalNumber(this)"> checkbox9
<br>
<INPUT type=checkbox name="checkbox10" onClick="CheckTotalNumber(this)"> checkbox10
<br>
</form>



0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question