I'm trying to set and read a simple cookie however its proven to be more
difficult than I originally thought.
In the first Array named the_information,
[0] is the value of a text box named 'product'
[1] is the value of a text box named 'image'
[2] is the value of a drop-down list named 'quantity'
all of these variables are located in form[0] of my HTML document.
I continue to get the MIE error 'cannot assign to '[obect]'.
I'v gone cross-eyed tweaking this block of code all weakend.
As a temporary way of displaying the cookie's saved values I have it alert them.
(which I haven't gotten to work yet)
I'v run out of ideas so any of your's would be much appeciated,
thanks-alot
function setCookie()
{
var the_information = new Array (3);
the_information[0] = document.forms[0].product.value;
the_information[1] = document.forms[0].image.value;
the_information[2] = document.forms[0].quantity[document.forms[0].quantity.selectedIndex].value;
var more_information = new Array(3);
more_information[0] = the_information[0];
more_information[1] = the_information[1];
more_information[2] = the_information[2];
var the_cookie = "product:more_information[0];image:more_information[1];quantity:more_information[2]";
my_cookie = "km1=" + escape(the_cookie);
document.cookie = my_cookie;
}
function readTheCookie()
{
var my_cookie = document.cookie;
var my_cookie = unescape(my_cookie);
var broken_cookie = my_cookie.split("=");
var the_values = broken_cookie[1];
var separated_values = the_values.split(";");
var property_value = "";
for (var loop = 0; loop < separated_values.length; loop++);
{
property_value = separated_values[loop];
var broken_info = property_value.split(":");
var the_property = broken_info[0];
var the_value = broken_info[1];
the_info[the_property] = the_value;
var prod = the_info["product"];
var imag = the_info["image"];
var quant = the_info["quantity"];
alert(prod + imag + quant);return false;
}
}
//-->
[All suggestions, advice or critisism welcome]
Thanks,
Kalan