JS implements the CheckBox check box option

  • 2020-06-03 05:54:41
  • OfStack

The CheckBox control is what we call a checkbox, usually used to turn an option on or off. This control is present in the Settings dialog box for most applications. The one we see that we can check is CheckBox.

This control indicates whether a particular state (that is, an option) is selected (on, with a value of 1) or cleared (off, with a value of 0). Using this control in your application gives the user the choice of "True/False" or "yes/no". Because CheckBox works independently of each other, users can select any number of CheckBox at the same time for a combination of options.

CheckBox check box JS implements all or nothing, easy, just insert 1 small js function...


<script language="javascript">
 function cli(Obj)
 {
 var collid = document.getElementByIdx_x("all")
 var coll = document.getElementsByName(Obj)
 if (collid.checked){
  for(var i = 0; i < coll.length; i++)
  coll[i].checked = true;
 }else{
  for(var i = 0; i < coll.length; i++)
  coll[i].checked = false;
 }
 }
 </script>

Below is a set of CheckBox check boxes html code

<input name=' Multiple option name ' type='checkbox' value='' id="all" onclick="cli(' Multiple option name ');">  Future generations 
<input name=' Multiple option name ' type='checkbox' value='' > A
<input name=' Multiple option name ' type='checkbox' value='' > B
<input name=' Multiple option name ' type='checkbox' value='' > C
<input name=' Multiple option name ' type='checkbox' value='' > D
<input name=' Multiple option name ' type='checkbox' value='' > E
<input name=' Multiple option name ' type='checkbox' value='' > F

Ok, you can copy 1 more code, change 1 more test...

This site here recommend this site to see this article: https: / / www ofstack. com article / 96022. htm

This is the end of this article, I hope you enjoy it.


Related articles: