• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

JavaScript Cookie Question

Mekhu

New Member
Hey guys... basically I want it so a user enter there name, strikes enter and a welcome message is displayed... not happening for me though...

------------------

<html>
<head>
<title></title>

<script language="JavaScript">
expireDate = new Date;
expireDate.setMonth(expireDate.getMonth()+6);
firstName = "";
if (document.cookie != "") {
firstName = document.cookie.split("=")[1];
}
function setCookie() {
firstName = document.myForm.nameField.value;
document.cookie = "firstName="+firstName+";expires=" +
expireDate.toGMTString();
}
</script>

</head>
<body>

<form name="myForm">
Name:
<input type="text" name="nameField" onBlur="setCookie()">
</form>

<script language="JavaScript">
if (document.cookie != "") {
document.write("<br>Welcome to my site, " + firstName);
}
</script>


</body>
</html>
 
Back
Top