Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple Code failure

Status
Not open for further replies.

athanman

Technical User
Dec 10, 2007
1
US
Why does this not work. I am not seeing it:

<!-- saved from url=(0022) -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Personal Preferences</title>

<script type="JavaScript">




function setCookie() {
var expiresDate = new Date();
expiresDate.setFullYear(expiresDate.getFullYear() +1);
document.cookie = encodeURI("user_name=" + document.forms[0].user_name.value) + "; expires=" + expiresDate.toUTCString();
document.cookie = encodeURI("user_color=" + document.forms[0].user_color.value) + "; expires=" + expiresDate.toUTCString();
window.alert("Your name and favorite color have been saved in a cookie.");

}


</script>

</head>
<body>

<form action="">
<p>Name: <input type="text" name="user_name" /><br />
Favorite color: <input type="text" name="user_color" /></p>
<p><input type="button" value="Set Cookie" onclick="setCookie();" /></p>
</form>


</body>
</html>
 
I don't know if this is the problem, but this sure does not look correct to me:

<p><input type="button" value="Set Cookie" onclick="setCookie();"  /></p>

Try removing the semicolon and see if that works.


mmerlinn

"Political correctness is the BADGE of a COWARD!"

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top