Hi All,
Im a novice student trying to complete a project. I am trying to give the user 2 simple options using a HTML formfor a background colour. That colour will then be implemented across 3 simple pages. I am using IIS and can ONLY use asp classic and html. I am close but doing something wrong and I cannot figure it out:
This is code from 2 pages (without the form page) that work. I have hard coded in the 'User option'.
DefaultSite.asp
<html>
<head>
<link rel="stylesheet" type="text/css" href="styleCookieWorks1.asp">
</head>
<body>
<%
response.write("Asp Project Sample")
%>
<p>
My red green test
</p>
</body>
</html>
styleCookieWorks1.asp
<%
Response.Cookies("choice")("bgc") = "1" I have hardcoded the user choice in here
bgc = Request.Cookies("choice")("bgc")
if(bgc = "1") then
response.write("body{background-color:red}")
elseif (bgc = "2") then
response.write("body{background-color:green}")
end if
%>
Now when I add in a form page that will take the place of me hardcoding the option in, it does not work. Why, I dont know?
StyleForm.htm (instead of hardcoding the option in)
<html>
<head>
<title>Style Form Page</title>
</head>
<body>
<form method="post" action="styleCookie2.asp">
<h4>Select the Background colour you would like.</h4>
<input type="radio" name="bGcol" value="1" /> : Red<br />
<input type="radio" name="bGcol" value="2"/> : Green<br />
<input type="submit" value="Submit" />
</form>
</body>
</html>
styleCookie2.asp (asp page where the option selected from the form page is processed)
<%
dim var
var=Request.Form("bGcol")
Response.Cookies("choice")("bgc") = var
bgc = Request.Cookies("choice")("bgc")
if(bgc = "1") then
response.write("body{background-color:red}")
elseif (bgc = "2") then
response.write("body{background-color:green}")
end if
%>
<html>
<body>
<br>
<A HREF = "defaultSite.asp">Continue to default Site</A>
</body>
</html>
defaultSite.asp (this the first page of my website where the background choice should be implemented from thestyleCookie2.asp, but is not)
<html>
<head>
<link rel="stylesheet" type="text/css" href="styleCookie2.asp">
</head>
<body>
<%
response.write("Asp Project Sample")
%>
<p>
Trevor red green test
</p>
</body>
</html>
I count myself as a novice at this so I would appreciate it if any advice is not too technical, ie dont assume I should know something :0)
Any help would be greatly appreciated.
Regards, Bubs