In some web applications, such as voting systems, when we conduct multiple votes, we require users to select only a few items at most to vote, which means that the number of check boxes can be selected at most.
So how to set the largest few, we need to do some simple script processing. The following codes are all reprinted from the Internet, and the author is unknown.
For example, the following code solves related problems:
]
The most important thing to pay attention to when changing the code It is the name prefix of
//checkbox element, in this case sample1, sample2, sample3...
var sCtrlPrefix = "sample";
and
//number of checkbox elements, in this case there are 10 ;
var iMaxCheckbox = 10;
If the name prefix and number of elements of the checkbox element are slightly different from those defined in the page, the script will become invalid.
Therefore, the following script functions are universal:
If you need to introduce external Js, you need to refresh to execute
]
[Ctrl A select all Note: If you need to introduce external Js, you need to refresh to execute ]