Chapter 11 -- Page 386
Hi,
I am stuck with changing themes. I have checked the code in changeSiteTheme.asp and my template. It is same as of the downloadable code from this web site.
When I select different theme, it does show me its image in Preview fieldset then I click Apply button. It doesn't apply the theme. It remains to default theme. I check the Cookie file and the value has changed in cookie but theme doesn't get changed.
Anyways following is copy of my code:
mainTemplate.dwt.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<html>
<head>
<title>GlobalSoccerEvents.com - Your Source for Soccer Events Aroung the Globe</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<% Dim iTheme
if Len(Request.Cookies("SiteTheme")) > 0 Then
iTheme = Request.Cookies("SiteTheme")
Else
iTheme = 1 'our default theme
End If
%>
<link href="../Styles/mainStyles<%=iTheme%>.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="../Images/logo.gif"></td>
<td align="right"><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><a href="../home.asp" title="Home Page" id="home">Home</a></td>
<td> </td>
<td><a href="../events.asp" title="View Events" id="events">Events</a></td>
<td> </td>
<td><a href="../mysite.asp" title="Manage MySite" id="mysite">My Site</a></td>
<td> </td>
<td><a href="../admin/admin.asp" title="Administrator Access" id="admin">Admin</a></td>
<td> </td>
<td><a href="../login.asp" title="Login" id="login">Login</a></td>
<td> </td>
<td><a href="../logout.asp" title="Logout" id="logout">Logout</a></td>
</tr>
</table></td>
</tr>
</table>
<br>
<script language="JavaScript" type="text/JavaScript">
var sPageName = '<%=Request.ServerVariables("SCRIPT_NAME")%>';
sPageName = sPageName.substr(sPageName.lastIndexOf('/') + 1).toLowerCase();
sPageName = sPageName.substr(0, sPageName.lastIndexOf('.'));
if (document.getElementById(sPageName))
{
document.getElementById(sPageName).style.fontWeigh t = 'Bold';
document.getElementById(sPageName).style.fontSize = '14pt';
}
</script><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><h2>- Page Title Here -</h2></td>
</tr>
<tr>
<td>- Page Content Here -</td>
</tr>
<tr>
<td align="center"><br>
<br><br><br><br><br>
- Footer Here -</td>
</tr>
</table>
</body>
</html>
changeSiteTheme.asp
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<% If request.Form("btnApply") <> "" Then
Response.Cookies("SiteTheme") = Request.Form("lstTheme")
response.Cookies("SiteTheme").Expires = Date() + 30
End If
%>
<html>
<head>
<title>GlobalSoccerEvents.com - Your Source for Soccer Events Aroung the Globe</title>
<script language="JavaScript" type="text/JavaScript">
function changeThemeImage()
{ var iSelectedIndex = document.frmSelectTheme.lstTheme.selectedIndex;
var iSelectedValue = document.frmSelectTheme.lstTheme[iSelectedIndex].value;
document.images["imgSiteTheme"].src = 'images/theme' + iSelectedValue + '.gif';
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<% Dim iTheme
if Len(Request.Cookies("SiteTheme")) > 0 Then
iTheme = Request.Cookies("SiteTheme")
Else
iTheme = 1 'our default theme
End If
%>
<link href="Styles/mainStyles<%=iTheme%>.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><img src="Images/logo.gif"></td>
<td align="right"><table border="0" cellspacing="0" cellpadding="0">
<tr>
<td><a href="home.asp" title="Home Page" id="home">Home</a></td>
<td> </td>
<td><a href="events.asp" title="View Events" id="events">Events</a></td>
<td> </td>
<td><a href="mysite.asp" title="Manage MySite" id="mysite">My Site</a></td>
<td> </td>
<td><a href="admin/admin.asp" title="Administrator Access" id="admin">Admin</a></td>
<td> </td>
<td><a href="login.asp" title="Login" id="login">Login</a></td>
<td> </td>
<td><a href="logout.asp" title="Logout" id="logout">Logout</a></td>
</tr>
</table></td>
</tr>
</table>
<br>
<script language="JavaScript" type="text/JavaScript">
var sPageName = '<%=Request.ServerVariables("SCRIPT_NAME")%>';
sPageName = sPageName.substr(sPageName.lastIndexOf('/') + 1).toLowerCase();
sPageName = sPageName.substr(0, sPageName.lastIndexOf('.'));
if (document.getElementById(sPageName))
{
document.getElementById(sPageName).style.fontWeigh t = 'Bold';
document.getElementById(sPageName).style.fontSize = '14pt';
}
</script><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td><h2>Change Site Theme</h2></td>
</tr>
<tr>
<td>
<table width="670" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="230" valign="top">
<form action="changeSiteTheme.asp" method="post" name="frmSelectTheme">
<fieldset style="height: 200px;"><legend>Select a Theme</legend>
<span style="display: block; padding: 10px;">
<select name="lstTheme" size="3" onChange="changeThemeImage();">
<option value="1">Default Theme</option>
<option value="2">Orange and Black</option>
<option value="3">Large Fonts</option>
</select><br><br>
<input name="btnApply" type="submit" value="Apply">
</span>
</fieldset>
</form>
</td>
<td width="40" valign="top"> </td>
<td width="400" valign="top">
<fieldset style="height: 200px;"><legend>Preview</legend>
<span style="dislpay: block; padding: 10px;">
<img src="Images/theme1.gif" name="imgSiteTheme" width="400" height="148" id="imgSiteTheme">
</span>
</fieldset>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center"><br>
<br><br><br><br><br>
- Footer Here -</td>
</tr>
</table>
</body>
</html>
TIA,
Omer
|