0

I have tried searching through SO where i get some sort of idea how to enable setItem and getItem in ie9 but no use it was not working in ie 9

function assignValue() {
    var checkedRadioValue = -1;
    if (document.getElementById("ug").checked)
    {
        checkedRadioValue = 1;
    }
    else if(document.getElementById("pg").checked)
    {
        checkedRadioValue = 2;
    }
    else if(document.getElementById("cu").checked)
    {
        checkedRadioValue = 3;
    }
    //localStorage.setItem("CheckedRadioValue", checkedRadioValue);

    localStorage.setItem("CheckedRadioValue", checkedRadioValue);
}

Actually i am trying some thing like this for ie9

if(window.localStorage) { 
    localStorage.setItem("CheckedRadioValue", checkedRadioValue);
}

like this I am trying to get the value using localstorage in ie9 this was working perfectly in chrome, firefox

var checkedRadioValue = parseInt(localStorage.getItem("CheckedRadioValue"));
    if (checkedRadioValue != -1) {
        if (checkedRadioValue === 1) {
            $('.local_Field ').each(function() {
                $(this).rules("remove","required");
            });
        }
        else if (checkedRadioValue === 3){
            $('.local_Field').each(function() {
                $(this).rules("remove","required");
            });
            $("#edu_info").hide();
            $(".local_Field").removeClass('required_Field');
            //$('.local_Field ').addClass('chumma');
        }
        else{
            $('.local_Field ').each(function() {
                $(this).rules("add","required");
            });
             $(".local_Field").addClass('required_Field');
        };
        //localStorage.removeItem("CheckedRadioValue");
    }

This what the error i am geting in IE10

SCRIPT5007: Unable to get property 'getItem' of undefined or null reference 

Thanks in advance

Ash
  • 2,108
  • 2
  • 17
  • 22
Mr.M
  • 1,472
  • 3
  • 29
  • 76

0 Answers0