Hi
I had an issue which I've already fixed here: https://usergroup.netsuite.com/users/showthread.php?p=92550#post92550 regarding holding the value of a checkbox from page to page using the window.name reference.
Now, I have decided to learn a bit more and try getting it to work using cookies as I'm sure it will be very handy down the track. I have Frankensteined some coding from w3schools.com and my own code to try and get cookies happening, so that's why my variables look rather strange.
I can't seem to get it happening though. The checkbox does the desired job, but I can't get it to keep it's value from page to page.
Here is the code of my test file file:///C:/filelocationgoeshere/pop-up-cookie3.html if anyone cares to take a look and offer some pointers:
<html> <head> <script type="text/javascript"> function display(checkboxSelected) { var contents = "" contents += checkboxSelected.name contents += checkboxSelected.checked document.bookForm.allowcartpop.value = contents } function show_cartinfo() { if (document.bookForm.allowcartpop.value != 'nopopuptrue') { alert("Your fabulous selection will now be added to your shopping basket which can be viewed on the top left next to the picture of the shopping trolley." + "n" + "n" + "When you have finished shopping click View Basket to see your cart contents and proceed to the checkout." + "n" + "n" + "To disable this message from appearing again click the checkbox below your shopping cart."); } } </SCRIPT> <script type="text/javascript"> 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 ""; } 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.toGMTString()); } function checkCookie() { username=getCookie('username'); if (username!=null && username!="") { alert('Welcome again '+username+'!'); } else { username=prompt('Please enter your name:',""); if (username!=null && username!="") { setCookie('username',username,0.0001); } } } </script> </head> <body> <FORM NAME="bookForm"> <script type="text/javascript"> username=getCookie('username'); if (username != 'nopopuptrue') { document.write('<INPUT TYPE="checkbox" NAME="nopopup" onClick="display(this)" onChange="setCookie('username',contents,365)" >Disable Cart pop-up message'); } else { document.write('<INPUT TYPE="checkbox" NAME="nopopup" onClick="display(this)" checked onChange="setCookie('username',contents,365)">Disable Cart pop-up message'); } </script> <input type="hidden" name="allowcartpop"> <input type="button" onClick="show_cartinfo()" name="button" onMouseUp="window.location='file:///C:/filelocationgoeshere/pop-up-cookie3.html'"> </FORM> </body> </html>