0

I'm beginning to think that I don't have the eyes for this. Chrome's JS console is telling me that on line 28 "setCookie is not defined". What does this mean? I've looked at the function portion and it looked the same as my book but I have missed punctuation/spelling before. Thanks again whoever answers.

Jake

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>Personal Preferences</title>


<script type="JavaScript">
<!-- HIDE FROM INCOMPATIBLE BROWSERS

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.");
}

// STOP HIDING FROM INCOMPATIBLE BROWSERS -->
</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>
2
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by djcrab
0

Ok, I tried it as "text/javascript" and it worked of course. My question now is why does my book say to declare the script as "Javascript"? I went back and double checked and it definitely reads that way but doesn't say why. Typo or what?

0

It could work only on IE, but on certain browsers, it doesn't. The type you give 'text' is the most standard for any browser to understand. The same goes with css (text/css).

0

Ok. My book may be a bit outdated on some things I'm learning. It's copyright date is 2004...Thank you.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.