Select One Checkbox at a time?

Posted by Laghaterohan under jQuery on 1/4/2011 | Points: 10 | Views : 12480 | Status : [Member] | Replies : 4
Hello,

Can any one tell me how to check only one check box at a time from the CheckBox list using Jquery?



Thanks!
Happy Coding :)

Best Regards,
Rohan Laghate



Responses

Posted by: Karthikanbarasan on: 1/4/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
Hi,

You can loop through and see for the checked one... see the below code

$("input[@type=checkbox][@checked]").each( 

function() {
// Insert code here
}
);


Thanks
Karthik
www.f5Debug.net

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Laghaterohan on: 1/4/2011 [Member] Starter | Points: 25

Up
0
Down
Hi,
Thanks....:)

Is there any code that will allow me to check only one checkbox at a time...


Thanks!
Happy Coding :)

Best Regards,
Rohan Laghate

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 1/5/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
var checkboxes = $(':checkbox.myCheckboxGroup');

checkboxes.click(function(){
var self = this;
checkboxes.each(function(){
if(this!=self) this.checked = ''
})
})


This code might be working for you

Thanks
Karthik
www.f5Debug.net

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Laghaterohan on: 1/5/2011 [Member] Starter | Points: 25

Up
0
Down
Thanks:)

i shall check the code..

Best Regards,
Rohan Laghate

Laghaterohan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response