Home > Web Front-end > JS Tutorial > js code to limit the maximum number of options for a check box_form effects

js code to limit the maximum number of options for a check box_form effects

WBOY
Release: 2016-05-16 19:00:04
Original
1045 people have browsed it

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:


[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute
]

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:
J
[Ctrl A Select All Note:
If you need to introduce external Js, you need to refresh to execute
]
I
J
[Ctrl A select all Note: If you need to introduce external Js, you need to refresh to execute ]
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template