0

i want the the checkbox behave like radio but should be able to checked or unchecked and save the state checkbox in cookie. Here is the cookie code, from here or jsfiddle here

$(".chb").each(function() {
var mycookie = $.cookie($(this).attr('name'));
if (mycookie && mycookie == "true") {
    $(this).prop('checked', mycookie);
}
});
$(".chb").change(function() {
$.cookie($(this).attr("name"), $(this).prop('checked'), {
    path: '/',
    expires: 365
});
});

i try added this code in .change but the cookie still save multiple state. its working fine without combine with cookie script. anyone can help?

$(".chb").not(this).prop('checked', false);
Community
  • 1
  • 1
user3613026
  • 191
  • 1
  • 16
  • If you want checkboxes that behave like radios, why not use radio buttons ? – adeneo Jan 31 '15 at 21:19
  • @adeneo because the requirement, it should look like checkbox. i know, i can simply use radio. unless there is other option to convert radio interface to look like checkbox. :( – user3613026 Jan 31 '15 at 21:30
  • one more thing, if use radio button, you cannot uncheck the checked radio. its like convert on paper exam to online exam. – user3613026 Jan 31 '15 at 21:36

0 Answers0