Get Checkbox Value using javascript


<html>
<head>
<title>JavaScript select checkbox</title>
<script>
function selectCheckBox()
{
  var e= document.frm.elements.length;
  var cnt=0;

  for(cnt=0;cnt<e;cnt++)
  {
    if(document.frm.elements[cnt].name=="id"){
     alert(document.frm.elements[cnt].value)
    }
  }
}
</script>
</head>

<body>
<form name="frm">
<input type="checkbox" name="id" value="1">
<input type="checkbox" name="id" value="2">
<input type="checkbox" name="id" value="3">
<input type="checkbox" name="id" value="4">
<input type="checkbox" name="id" value="5">
<input type="button" name="goto" onClick="selectCheckBox()" value="Check">
</form>
</body>
</html>

The example is showing how to get value from separate name checkbox in JavaScript.

<html>
<head>
<title>JavaScript select checkbox</title>
<script>
function selectCheckBox()
{
     alert(document.frm.id1.value)
     alert(document.frm.id2.value)
     alert(document.frm.id3.value)
}
</script>
</head>

<body>
<form name="frm">
<input type="checkbox" name="id1" value="1">
<input type="checkbox" name="id2" value="2">
<input type="checkbox" name="id3" value="3">

<input type="button" name="goto" onClick="selectCheckBox()" value="Check">
</form>
</body>
</html>

1 comments:

Anonymous said...

goyard outlet
bapesta shoes
bape
fear of god essentials hoodie
off white clothing
a bathing ape
kyrie irving shoes
kyrie 8 shoes
hermes
hermes bag

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|