Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Closed Thread
Old 04-22-2006, 07:57 PM   #1 (permalink)
 
Newb Techie

Join Date: Jan 2006

Posts: 39

smartydebater

Default Javascript Problem

Okay, the user will either have a cookie called banner with a value of 1 or 2.

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Validation</title>
<script language="text/javascript">
function Validation()
{
function ReadCookie()
{
	with (document.CookieReader)
		{ if (document.cookie.banner == "1")
			{alert ("1") }
		if (document.cookie.banner == "2")
		   {alert ("2") }
		}
}
}
</script>
		

</head>

<body>
<input type="button" value="Click Me!"onClick="Validation()">
</body>
</html>
What I'm wondering is, why this code doesn't work, and also if I can say ==1 or ==2 like I did and have it be checking if the value of the cookie is 1 or 2. Anybody have an ideas?
smartydebater is offline  
Old 04-23-2006, 09:18 AM   #2 (permalink)
office politics's Avatar
 
It's all just 1s and 0s

Join Date: Jan 2004

Location: in the lab

Posts: 4,425

office politics will become famous soon enough

Default

you have to call the function after you define what it does

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Validation</title>
<script language="text/javascript">
function Validation()
{
function ReadCookie()
{
	with (document.CookieReader)
		{ if (document.cookie.banner == "1")
			{alert ("1") }
		if (document.cookie.banner == "2")
		   {alert ("2") }
		}
}
ReadCookie();
}
</script>
		

</head>

<body>
<input type="button" value="Click Me!"onClick="Validation()">
</body>
</html>

office politics is offline  
Old 04-24-2006, 08:04 PM   #3 (permalink)
 
Newb Techie

Join Date: Jan 2006

Posts: 39

smartydebater

Default

I think that it's not reading the cookies value. Am I right?
smartydebater is offline  
Old 04-24-2006, 11:56 PM   #4 (permalink)
office politics's Avatar
 
It's all just 1s and 0s

Join Date: Jan 2004

Location: in the lab

Posts: 4,425

office politics will become famous soon enough

Default

it never writes a cookie either.
office politics is offline  
Old 04-25-2006, 01:09 AM   #5 (permalink)
 
Banned

Join Date: Apr 2006

Posts: 237

Tordenskjold

Default

yeh i think cs is right
Tordenskjold is offline  
Old 04-25-2006, 09:02 PM   #6 (permalink)
 
Newb Techie

Join Date: Jan 2006

Posts: 39

smartydebater

Default

Anybody know how I could fix it so it would read the value and write the cookie?
smartydebater is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On