
theworkz
Deleted
Jun 4, 2000, 4:59 PM
Post #3 of 3
(793 views)
|
Re: Need Some Help With a cookie..
[In reply to]
|
Can't Post
|
|
nope.. that didnt work.. lemme give you the rest of the code for the cookie.. this is in the <head> of the page (with explanations) ------------------------------------ <SCRIPT LANGUAGE = "JavaScript"> <!-- // Use this function to retrieve a cookie. function getCookie(name){ var cname = name + "="; var dc = document.cookie; if (dc.length > 0) { begin = dc.indexOf(cname); if (begin != -1) { begin += cname.length; end = dc.indexOf(";", begin); if (end == -1) end = dc.length; return unescape(dc.substring(begin, end)); } } return null; } // Use this function to save a cookie. function setCookie(name, value, expires) { document.cookie = name + "=" + escape(value) + "; path=/" + ((expires == null) ? "" : "; expires=" + expires.toGMTString()); } // Use this function to delete a cookie. function delCookie(name) { document.cookie = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT" + "; path=/"; } // Function to retrieve form element's value. function getValue(element) { var value = getCookie(element.name); if (value != null) element.value = value; } // Function to save form element's value. function setValue(element) { setCookie(element.name, element.value, exp); } var exp = new Date(); exp.setTime(exp.getTime() + (1000 * 60 * 60 * 24 * 31)); //--> </SCRIPT> --------------------------- and here is the form for getting and recieving data from the cookie.. --------------------------- <FORM METHOD="POST" ACTION="http://www.whatever.com/cgi-bin/search.pl" onSubmit="submitonce(this)"> <TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" BGCOLOR="#FFFFFF"> <TR> <TD><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0" bgcolor="#FFFFFF"> <TR><TD ALIGN="center" VALIGN="middle"> <INPUT TYPE="text" NAME=zip SIZE="5" onFocus="getValue(this)" onChange="setValue(this)" VALUE="" STYLE="font-family:Courier New;font-size:10pt;"><INPUT TYPE="submit" VALUE="Get It" WIDTH="120"></TD> </TR></TABLE></TD> </TR> </TABLE> </FORM> ---------- look at past messages for what im trying to do.. thanks in advance Luke
|