In article <4c************ **************@ posting.google. com>,
ym*@kicon.com enlightened us with...
Hi,
I want to put a value in a cookie. The following code does not work.
It does not store the box1.value in the cookie. How can I fix it?
<input type="text" name="box1" onblur=document .cookie="user=" +
box1.value>
Chris
Try
<input type="text" name="box1" onblur="setCook ie('user',this. value,'')">
The function setCookie is as follows.
function setCookie(cooki eName, cookieValue, expireDate)
{
/* Pass in three strings - the name of the cookie, the value, and the
expire date.
Pass in a "" empty string for expireDate to set a session cookie
(no expires date).
Pass in any other date for expire as a number of days to be added
to today's date. */
if (expireDate == "")
{
expires = "";
}
else
{
expires = new Date();
expires.setDate (expires.getDat e() + expireDate);
expires = expires.toGMTSt ring();
}
document.cookie = cookieName+"="+ cookieValue+";e xpires="+expire s;
}
--
-------------------------------------------------
~kaeli~
Jesus saves, Allah protects, and Cthulhu
thinks you'd make a nice sandwich.
http://www.ipwebdesign.net/wildAtHeart http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------