Hi all,
I am having a nightmare of a time trying to save a form value into a cookie. I am using the following:-
function createCookie(name, value, days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60
var expires = “; expires=”+date.toGMTString();
}
else var expires = “”;
document.cookie = name+”=”+value+expires+”; path=/”;
}
and then
createCookie(‘TestCookie’,’TestVal’,7)
createCookie(‘VisitorName’, document.forms[0].name.value, 365)
TestCookie is saved OK but VisitorName won’t. What is wrong with passing document.forms[0].name.value as the value for VisitorName ?
Or is there another way to do this?
Cormac