Back to Scripts page
Click in the box below, select all and copy to grab the script
<HTML> <HEAD> <TITLE>Set a cookie based on a form</TITLE> <SCRIPT LANGUAGE=JAVASCRIPT> <!-- Hide script from older browsers // This script copyright 1997, Tom Negrino and Dori Smith. // This script is from "JavaScript for the WWW, Visual QuickStart Guide, 2nd Ed." // For more information, see <http://www.chalcedony.com/javascript/>. // This script may be used and modified, but the copyright notice must remain intact. expireDate = new Date expireDate.setYear(expireDate.getYear()+1) userName = "" if (document.cookie != "") { userName = document.cookie.split("=")[1] } function setCookie() { userName = document.myForm.nameField.value document.cookie = "userName="+userName+";expires=" + expireDate.toGMTString() } // End hiding script --> </SCRIPT> </HEAD> <BODY BGCOLOR=WHITE> <FORM NAME=myForm><H1> Enter your name:<INPUT TYPE="text" value="&{userName};" name=nameField onBlur="setCookie()"> </H1></FORM> </BODY> </HTML>