I am not a programmer. I am trying to use a cookie script that remembers the last drop down menu selection.
I found a script that works but it does only a session cookie. How do I add an expiration date to the cookie in this script?
<head>
<script>
function SETcookie() {
document.cookie = "Selected=" + document.getElementById('myList').selectedIndex;
}
function GETcookie() {
if (document.cookie) {
eval(document.cookie);
document.getElementById('myList').selectedIndex = Selected;
}
}
</script>
</head>
<body onLoad="GETcookie()">
<select id="myList" onChange="SETcookie()">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
<option value="4">Option 4</option>
</select>
</body>
try
PS. The value 1000*60*60*24*365 = 1 Year
To Get the selected index try this GETcookie:
May be this will help
You could try this:
Try this:
c_name
is the name of the cookiec_value
is the cookie valueexdays
is the number of days you want the cookie to expire after