Jump to content


Using a query string to change a CSS class name

  • Please log in to reply
No replies to this topic

#1 jim28100

  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 09 October 2006 - 11:14 AM

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
<style type="text/css">
#link1 {
background-color: #D7EBB0;

Example of corresponding ‘menu’ link.
<td id="link1" 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>


I was hoping for something like www.xyz.com/ banks.php#3?myLink = #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.)


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users