tags:

views:

66

answers:

1

Hi I need a sample code to get the value of selected checkbox. The checkboxes are mutually exclusive and I would like to get the selected checkbox value on the click of a button Thanks

A: 

selected checkbox??

maybe you want checked checkbox....

html

<input type="checkbox" name="Checkbox1">
<input type="checkbox" name="Checkbox2" checked="checked">
<input type="checkbox" name="Checkbox3">
<input type="button" name="button1" value="see checked">

jQuery

$(function(){
   $('input:button').click(function(){
      alert($('input:checkbox:checked').attr('name'));
   })
})

if multiple are checked

$(function(){
   $('input:button').click(function(){
       $('input:checkbox:checked').each(function(){
           alert($(this).attr('name'));
       });
   })
})

demo

Reigel
Thanks Reigel. thats done it
tom