Search code examples
jquerycookiesradio-button

How to set cookie and refresh page after radio button is clicked?


I'm trying to pass a radio button value to a cookie and refresh my page on click. My code:

Inheritance Line:
<label><input name='inheritanceline' type='radio' value="father" checked ></input>Father</label>
<label>
<input name='inheritanceline' type='radio' value="mother"></input>Mother</label>

$("input:radio[name=inheritanceline]").change(function () {
if ($(this).attr("checked") == "checked") {
    $.cookie('inheritanceline', $(this).val());
}
window.location.reload();
});

But it doesn't work because the page is not refreshed after the click. How should I change my code for it to work correctly?


Solution

  • I think u might be probably using an older jQuery version.Try using version greater than 1.8 mate and then check it out.Try the fiddle made using ur code mate..:)

    Jsfiddle

    http://jsfiddle.net/Q2gJD/