Closed Thread Icon

Topic awaiting preservation: Can someone see the error of my ways? I'v gone cross-eyed trying to! (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=9026" title="Pages that link to Topic awaiting preservation: Can someone see the error of my ways? I&amp;#039;v gone cross-eyed trying to! (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Can someone see the error of my ways? I&#039;v gone cross-eyed trying to! <span class="small">(Page 1 of 1)</span>\

 
Kalan m
Nervous Wreck (II) Inmate

From: stirling, ON Can.
Insane since: Feb 2004

posted posted 02-15-2004 23:09

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

hyperbole
Paranoid (IV) Inmate

From: Madison, Indiana, USA
Insane since: Aug 2000

posted posted 02-16-2004 19:00

In the ReadTheCookie function you assign the_value to the_info[the_property] but you haven't declared the_info.

If this is a misprint and you meant to assign the_value to the_information you still have a problem because you declared the_information inside setCookie so ReadTheCookie won't be able to see it.

If you mean to assign the_value to the_information, move the declaration of the_information outside the scope of any function so all functions will be able to see it.




-- not necessarily stoned... just beautiful.

« BackwardsOnwards »

Show Forum Drop Down Menu