therealphil
09-09-2003, 05:58 AM
Hi
I have a piece of Javascript that validates data entered into an HTML form. At the end of my form are three lines of code. Each one calls a function, called setCookie, which sets a cookie containing the values of some of the form fields.
The problem is that when I run the script, only the last cookie actually gets set, as if each of the three cookies overwrites the cookie before it.
I thought that my field values weren't being properly assigned to the cookie values, but I modified my code to only set one cookie, and I did this with each of my three cookies and they worked fine. If I try to set more than one cookie, I always end up with only the last cookie being set.
Here are my three lines of code:
setCookie("vecProducts",products[0] +','+ products[1] +','+ products[2],";path=/;","");
setCookie("vecDownloadorCD",Download +','+ CD +','+ DownloadCD,";path=/;","");
setCookie("vecModules",document.EvalForm.webother.value,";path=/;","");
This is the 'setCookie' function:
// setCookie function
function setCookie(cookieName, cookieValue, cookiePath, cookieExpires){
cookieValue = escape(cookieValue);
document.cookie = cookieName + "=" + cookieValue + ";expires=" + cookieExpires + cookiePath;
}
Here is the page the code is on:
http://www.vector-networks.com/test/products/download.htm
Thanks, Phil
I have a piece of Javascript that validates data entered into an HTML form. At the end of my form are three lines of code. Each one calls a function, called setCookie, which sets a cookie containing the values of some of the form fields.
The problem is that when I run the script, only the last cookie actually gets set, as if each of the three cookies overwrites the cookie before it.
I thought that my field values weren't being properly assigned to the cookie values, but I modified my code to only set one cookie, and I did this with each of my three cookies and they worked fine. If I try to set more than one cookie, I always end up with only the last cookie being set.
Here are my three lines of code:
setCookie("vecProducts",products[0] +','+ products[1] +','+ products[2],";path=/;","");
setCookie("vecDownloadorCD",Download +','+ CD +','+ DownloadCD,";path=/;","");
setCookie("vecModules",document.EvalForm.webother.value,";path=/;","");
This is the 'setCookie' function:
// setCookie function
function setCookie(cookieName, cookieValue, cookiePath, cookieExpires){
cookieValue = escape(cookieValue);
document.cookie = cookieName + "=" + cookieValue + ";expires=" + cookieExpires + cookiePath;
}
Here is the page the code is on:
http://www.vector-networks.com/test/products/download.htm
Thanks, Phil