Js to get the checkbox value, js to get the checkbox Value
The example in this article describes how js obtains the checkbox value. Share it with you for your reference. The specific implementation method is as follows:
Copy codeThe Code is as follows: <Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
<Title> js </title>
</Head>
<Script language = "javascript">
Function aa (){
Var r = document. getElementsByName ("r ");
For (var I = 0; I <r. length; I ++ ){
If (r [I]. checked ){
Alert (r [I]. value + "," + r [I]. nextSibling. nodeValue );
}
}
}
</Script>
<Body>
<Form name = "form1" method = "post" action = "">
<Input type = "checkbox" name = "r" value = "1"> a <br>
<Input type = "checkbox" name = "r" value = "2"> B <br>
<Input type = "checkbox" name = "r" value = "3"> c <br>
<Input type = "checkbox" name = "r" value = "4"> d <br>
<Input type = "checkbox" name = "r" value = "5"> e <br>
<Input type = "checkbox" name = "r" value = "6"> f <br>
<Input type = "checkbox" name = "r" value = "7"> g <br>
<Input type = "checkbox" name = "r" value = "8"> h <br>
<Input type = "checkbox" name = "r" value = "9"> I <br>
<Input type = "checkbox" name = "r" value = "10"> j <br>
<Br>
<Input type = "button" onclick = "aa ()" value = "button">
</Form>
</Body>
</Html>
I hope this article will help you design javascript programs.