In a recruiting website, you can pinpoint the position of a user by limiting the number of job tags you choose. For example, provide the user with an alternative position label as a check box, limit the user to a maximum of 3, and prevent the user from continuing the selection when more than three are available.
check box in the survey, the recruitment site is very broad, today to introduce the Limit check box to select a number of methods:
Ideas:
OnClick Event listening for check boxes
Checkbox.onclick = function () {
//code block
}
Checked property for the Listener check box:
if (chckbox.checked) {
//code block
}
HTML code:
< input type= "checkbox" Name= "Sport"/> Basketball <br/>
< input type= "checkbox" Name= "Sport"/> Football <br/& gt;
< input type= "checkbox" Name= "Sport"/> Volleyball <br/>
< input type= "checkbox" Name= "Sport"/> Badminton <br />
< input type= "checkbox" Name= "Sport"/> Table tennis <br/>
< p> select up to three </p>
JavaScript code:
var sportselect = document.getelementsbyname (' Sport '),
maxnums = 3;
for (var i in Sportselect) {
sportselect[i]. onclick = function () {
var _sportselect = Document.getelementsbyname ( ' Sport '),
cnums = 0;
for (var i in _sportselect) {
if (i = = ' length ') break;
if (_sportselect[i].checked) {
cnums + +;
}
}
if (Cnums > Maxnums) {
this.checked = false;
Alert (' Up to three options only ');}}
The above limit check box to select the most of the implementation code is a small series to share all the content, hope to give you a reference, but also hope that we support the cloud-dwelling community.