Hi everyone,
I have a page in which I have a check box and some links. The check box reads "Open in New Window" and, when checked, will open the links in a new window. I want to save this setting so the user can set it once and not have to keep setting it each time they visit.
I have following JSP functions to save cookies (which I've tested and do work):
I have the following lines of code to save and load the cookies for the check boxes:Code:function setCookie(c_name,value,expiredays) { var exdate=new Date() exdate.setDate(exdate.getDate()+expiredays) document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate) } function getCookie(c_name) { if (document.cookie.length>0) { c_start=document.cookie.indexOf(c_name + "=") if (c_start!=-1) { c_start=c_start + c_name.length+1 c_end=document.cookie.indexOf(";",c_start) if (c_end==-1) c_end=document.cookie.length return unescape(document.cookie.substring(c_start,c_end)) } } return null }
However, when I reload the page, the check box always appears as checked, even if I leave the page and save the cookie. Is there something simple that I am missing? My cookies for text boxes work but not for check boxes.Code:// Load cookie document.getElementById("linksNewWindow").setAttribute('checked', getCookie("linksNewWindow")) // Save cookie setCookie("linksNewWindow", document.getElementById("linksNewWindow").checked, 100);
Thanks for any help.![]()



Reply With Quote

Bookmarks