Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 change bgcolor of <td> depending on page?
 New Topic  Topic Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Roland
Advanced Member

Netherlands
9335 Posts

Posted - 02 November 2001 :  07:25:20  Show Profile
I have a part of my site where I place lyrics and just replaced all hard code for the sub-menu with an include for easier navigation and maintenance. However, when someone goes to a page with (for example) Aerosmith lyrics, the <td> with Aerosmith in it should change bgcolor.
How can I implement this? The include file is in the folder http://www.frutzle.com/lyrics and all artists have their own sub directory.

Take a look at the above mentioned URL and compare it to http://www.frutzle.com/aboutsite.asp. The sub-menu is on the left side (can't miss it).

Thanks,
Roland


http://www.frutzle.com

paco
Junior Member

Spain
187 Posts

Posted - 02 November 2001 :  07:55:01  Show Profile
Some solutions would be to have one submenu include for each subsite or build the submenu dynamically (ASP)checking in which part of the site you are in so you have all the td's behave the same exept the desired one.

Go to Top of Page

Roland
Advanced Member

Netherlands
9335 Posts

Posted - 02 November 2001 :  08:38:48  Show Profile
Thanks for your reply paco.

I was wondering if it's possible to do something with an if statement that checks the url for a directory. If the directory is in the URL, it should change the bgcolor to white, else it should show it as is.

Of course that would have to be done for all <td>'s but that's a lot less work than having to edit one for each directory.

Could someone tell me if my idea is correct and how I would have to go about doing this (or something with the same result)? I don't know enough about ASP to build something like this myself

Roland
Go to Top of Page

GauravBhabu
Advanced Member

4288 Posts

Posted - 02 November 2001 :  08:44:14  Show Profile
strScriptName = request.servervariables("script_name")
if instr(1,strScriptName,"/DIRECTORYNAME/",1)> 0 then
Change color
end if
strScriptName = ""

GauravBhabu
There is only one miracle...That is LIFE! | It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying.
Go to Top of Page

Roland
Advanced Member

Netherlands
9335 Posts

Posted - 02 November 2001 :  08:49:28  Show Profile
quote:

strScriptName = request.servervariables("script_name")
if instr(1,strScriptName,"/DIRECTORYNAME/",1)> 0 then
Change color
end if
strScriptName = ""

GauravBhabu
There is only one miracle...That is LIFE! | It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying.



Uhohhh (I think I watched Teletubbies too much )

So I place that in the included file?
How does it know which color to change to what color?

Sorry for being such a complete ... well you know...
Go to Top of Page

paco
Junior Member

Spain
187 Posts

Posted - 02 November 2001 :  09:05:26  Show Profile
You could have the subsite names in an array and then do something like this:

strScriptName = request.servervariables("script_name")
For each subsite

if instr(1,strScriptName,subsite,1)> 0 then

' on this one you don't need onMouseOver or anything as it never changes
%>
<td bgcolor="#<%=colorSelected%> onClick="goToURL ...><a href="http://www.frutzle.com/lyrics/cats/" id="cats">
</td>
else

<td bgcolor="#DFDFDF" onmouseover="mOvr(this,cats);this.style.backgroundColor='#ECECEC'" onmouseout="mOut(this,cats);this.style.backgroundColor='#DFDFDF'" onClick="goToURL('parent','http://www.frutzle.com/lyrics/cats/');return document.returnValue;"><a href="http://www.frutzle.com/lyrics/cats/" id="cats">
</td>
end if

next

Not a copy paste solution but I hope it's enough to get the idea



Edited by - paco on 02 November 2001 09:06:34
Go to Top of Page

GauravBhabu
Advanced Member

4288 Posts

Posted - 02 November 2001 :  09:09:13  Show Profile
I don't know which <td> color you want to change and if you want to change all or just one particular.
However, If you are using variables for colors then just change the value of variable with new color you want to assign

GauravBhabu
There is only one miracle...That is LIFE! | It is difficult to IMPROVE on Perfection, There is no harm in Keep Trying.
Go to Top of Page

Roland
Advanced Member

Netherlands
9335 Posts

Posted - 02 November 2001 :  11:20:30  Show Profile
Well I got it working. I know it's probably not the best sollution but I'm an ASP newbie and I'm really glad you guys helped me 'cause I wouldn't have been able to do this without you.

Here's the code (for one item) that I used:
<%

strScriptName = request.servervariables("script_name")

if instr(strScriptName,"aerosmith")> 0 then
Response.Write("<tr><td bgcolor=#FFFFFF><h1>Aerosmith</td></tr>")
else
Response.Write("<tr><td bgcolor=#DFDFDF onMouseOver=""mOvr(this,aerosmith);this.style.backgroundColor='#ECECEC'"" onMouseOut=""mOut(this,aerosmith);this.style.backgroundColor='#DFDFDF'"" onClick=""goToURL('parent','http://www.frutzle.com/lyrics/aerosmith/');return document.returnValue;""><a href=""http://www.frutzle.com/lyrics/aerosmith/"" id=""aerosmith"">Aerosmith</a></td></tr>")
end if
%>


It even works with Netscrap... lol

Again, thank you for you time and patience *bows*
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.26 seconds. Powered By: Snitz Forums 2000 Version 3.4.07