CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 22nd, 2004, 03:16 PM
madchild madchild is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 149 madchild User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 14 h 19 m 25 sec
Reputation Power: 5
Within a Javascript function, how to pass a CSS class?

I include a CSS style sheet in my php page and within a javascript function, I pass a hard-coded color code. I want to change that hard-coded color code to be the color of one of the css classes. How do I go about doing this? The reason I need to do this, is because the css file included will change from user to user, but the class name (holding the color) always remains the same. Help please. Thanks in advance.

Reply With Quote
  #2  
Old July 22nd, 2004, 03:42 PM
madchild madchild is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 149 madchild User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 Days 14 h 19 m 25 sec
Reputation Power: 5
It's fairly messy, but this is what I attempted to do, and it doesn't work proper. Where change() and change2() are, use to be hard-coded colors.

PHP Code:
echo '<tr onmouseover="setPointer(this, \''.$row_count.'\', \'over\', \''.$row_color.'\', \'change()\', \'change2()\');" onmouseout="setPointer(this, \''.$row_count.'\', \'out\', \''.$row_color.'\', \'change()\', \'change2()\');" onmousedown="setPointer(this, \''.$row_count.'\', \'click\', \''.$row_color.'\', \'change()\', \'change2()\');">'


Code:
<script language="javascript" type="text/javascript">
	
	function change() {
		this.className="bgcolor1";
	}
	
	function change2() {
		this.className="bgcolor2";
	}
</script>


CSS Code is the following:
Code:
.bgcolor1 {
	background-color: #83a9be;
}
 
.bgcolor2 {
	background-color: #E54340;
}

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > Within a Javascript function, how to pass a CSS class?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT