1// Get checkbox values using checkbox's name
2
3<head>
4 <script>
5 function getCheckBoxValues(){
6 $('[name="checkname"]').each( function (){
7 alert($(this).val());
8 });
9 }
10 </script>
11 </head>
12 <body>
13 <input type="checkbox" name="checkname" value='1'/>
14 <input type="checkbox" name="checkname" value='2'/>
15 <input type="checkbox" name="checkname" value='3'/>
16 <input type="button" value="CheckBoxValues" onclick="getCheckBoxValues()"/>
17 </body>
18
19// Get only the values witch are checked
20
21function getCheckBoxValues(){
22 $('[name="checkname"]').each( function (){
23 if($(this).prop('checked') == true){
24 alert($(this).val());
25 }
26 });
27 }