kathyc
01-17-2009, 09:04 PM
Hi
I have JS cookie code that I have been using over the past little while and
it works.
But I'm having a problem reading cookies back on the website I'm
working on and I think it's because I'm using a window.location.href
in my code.
What I am trying to do is write 4 variables to cookies and then I
do a window.location.href to a new page. When I try to display the
cookies on this page using my getCookie function, I'm getting nothing.
Here is my code for the 1st web page....
function CheckProductForm(inp, form)
{
var bIsValid = true;
if (inp.value >= 5)
{
var sName = (eval ("document." + form + ".item_name" + ".value"));
var sNumber = (eval ("document." + form + ".item_number" + ".value"));
var sQuantity = (eval ("document." + form + ".quantity" + ".value"));
var sCostPerCourse = (eval ("document." + form + ".amount" + ".value"));
/* ERASE PRE-EXISTING COOKIES */
eraseCookie ("CourseName");
eraseCookie ("CourseNumber");
eraseCookie ("CourseQuantity");
eraseCookie ("CourseCost");
/* WRITE THESE VALUES TO A COOKE */
setCookie ("CourseName", sName, 3);
setCookie ("CourseNumber", sNumber, 3);
setCookie ("CourseQuantity", sQuantity, 3);
setCookie ("CourseCost", sCostPerCourse, 3);
/* FORWARD TO NEW CONTACT PAGE */
inp.value = "";
var sTemp = "To purchase 5 or more On-line programs, please complete the following information and an ETL representative will contact you.";
bIsValid = false;
window.location.href = "http://www.website.com/contact_store.html";
return bIsValid;
}
}
On the web page I'm forwading it to.....
function GetStoreInfo()
{
var sName = getCookie("CourseName");
alert (sName);
var sNumber = getCookie("CourseNumber");
var sQuantity = getCookie("CourseQuantity");
var sCost = getCookie("CourseCost");
}
I'm getting a blank alert box.
Any help would be appreciated.
Thanks.
I have JS cookie code that I have been using over the past little while and
it works.
But I'm having a problem reading cookies back on the website I'm
working on and I think it's because I'm using a window.location.href
in my code.
What I am trying to do is write 4 variables to cookies and then I
do a window.location.href to a new page. When I try to display the
cookies on this page using my getCookie function, I'm getting nothing.
Here is my code for the 1st web page....
function CheckProductForm(inp, form)
{
var bIsValid = true;
if (inp.value >= 5)
{
var sName = (eval ("document." + form + ".item_name" + ".value"));
var sNumber = (eval ("document." + form + ".item_number" + ".value"));
var sQuantity = (eval ("document." + form + ".quantity" + ".value"));
var sCostPerCourse = (eval ("document." + form + ".amount" + ".value"));
/* ERASE PRE-EXISTING COOKIES */
eraseCookie ("CourseName");
eraseCookie ("CourseNumber");
eraseCookie ("CourseQuantity");
eraseCookie ("CourseCost");
/* WRITE THESE VALUES TO A COOKE */
setCookie ("CourseName", sName, 3);
setCookie ("CourseNumber", sNumber, 3);
setCookie ("CourseQuantity", sQuantity, 3);
setCookie ("CourseCost", sCostPerCourse, 3);
/* FORWARD TO NEW CONTACT PAGE */
inp.value = "";
var sTemp = "To purchase 5 or more On-line programs, please complete the following information and an ETL representative will contact you.";
bIsValid = false;
window.location.href = "http://www.website.com/contact_store.html";
return bIsValid;
}
}
On the web page I'm forwading it to.....
function GetStoreInfo()
{
var sName = getCookie("CourseName");
alert (sName);
var sNumber = getCookie("CourseNumber");
var sQuantity = getCookie("CourseQuantity");
var sCost = getCookie("CourseCost");
}
I'm getting a blank alert box.
Any help would be appreciated.
Thanks.