简体   繁体   中英

Store the checkbox state in a cookie session in JSP using Javascript on page refresh

I have check-boxes defined in my below function in my JSP page. Now the checkboxValue is the state of the check-boxes defined in the page.

On-click of check-boxes the value is set to 'on' , I want to save the "on" state of the check-boxes in a browser session or cookie session so that on page refresh the clicked checkboxstates should be maintained or present in the check state only.

Can you please suggest me any approach to achieve this in my below code?

function() {
    var checkboxValue = this._checkbox.get('value');
    alert(checkboxValue);

    if (checkboxValue == 'on') {
        // do something
    } else {
        // dosomething else
}

尝试这个 :

$('#option_id').attr("selected","selected");

javascript

store:

sessionStorage.check=your checkboxvalue;

read:

sessionStorage.check;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM