Jump to content

Archived

This topic is now archived and is closed to further replies.

jim28100

Using a query string to change a CSS class name

Recommended Posts

I’m hoping this will be a simple question although my explanation may not be?

I am building an art gallery website.

Firstly, each of my pages has a side menu. The same menu is used on multiple pages and is brought in via a simple PHP ‘Include’. Each of the menu’s mouseOver and mouseOut states are controlled via an external CSS file. A page’s ‘down’ state is triggered by an on-page CSS ‘class’ style. The local ‘class’ style effectively supersedes the same ‘class’ name held in the external CSS file for the instance of this page. This effectively identifies which page is currently being viewed. – okay so far?

At present I have to hard-code the ‘downstate’ class for each page. The only thing that changes is the ‘class’ name. This is used as a unique ‘id’ name for each menu link.

Here is the rub – The above works fine as it stands as each artist has their own page. However, in the show section there maybe more that one artist on the same page. I need to offer a menu that allows visitors to select/view a particular artists work on the show page. This is okay because I can use a URL + ‘text anchor’ to target individual page areas. However, I’d like to show the downstate as active for whichever of the URL + ‘text anchor’ links were selected. At present I can only show the downstate for the whole page.

I’m hoping I could do this by using a ‘query string’ to change the downstate ‘class’ name? Below is the CSS I currently use to identify the downstate for each page.

-----------------------------------------------------------------
Example of the local CSS hard-coded in the <HEAD> of each page
[COLOR=SeaGreen]<style type="text/css">
[COLOR=Blue]#link1[/COLOR] {
background-color: #D7EBB0;
}
</style>[/COLOR]
-----------------------------------------------------------------
Example of corresponding ‘menu’ link.
[COLOR=SeaGreen]<td [COLOR=Blue]id="link1" [/COLOR] width="100%" height="18" onMouseOver="pviiClassNew(this,'overState')" onMouseOut="pviiClassNew(this,'outState')">
<a href="banks.php" onFocus="if(this.blur)this.blur()">Michael Banks</a></td>[/COLOR]

-----------------------------------------------------------------

I was hoping for something like [url=http://www.xyz.com/]www.xyz.com/[/url] banks.php#3?[color=blue]myLink[/color] = #link1 .
Thereby creating a generic class name/variable called ‘myLink’, which is then changed by the query string. Needless to say it doesn’t work.

Hope someone can HELP?
(I’m very new to this so please be gentle.)

Jim

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.