Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-08-2004, 02:51 PM   PM User | #1
alaios
Regular Coder

 
Join Date: Aug 2002
Posts: 433
Thanks: 3
Thanked 0 Times in 0 Posts
alaios is an unknown quantity at this point
textarea onClick?

Hi there... Do uknow how i can change the color of a textarea when a user clicks on it? Do u know which browsers support this feauture?Thx
alaios is offline   Reply With Quote
Old 08-08-2004, 04:03 PM   PM User | #2
Mr J
Senior Coder

 
Join Date: Aug 2002
Location: UK
Posts: 2,789
Thanks: 2
Thanked 14 Times in 14 Posts
Mr J is on a distinguished road
<textarea name="t1" onclick="this.style.backgroundColor='red' "></textarea>
Mr J is offline   Reply With Quote
Old 08-08-2004, 04:42 PM   PM User | #3
alaios
Regular Coder

 
Join Date: Aug 2002
Posts: 433
Thanks: 3
Thanked 0 Times in 0 Posts
alaios is an unknown quantity at this point
thx

Thx...do u know if this is possible using stylesheets?
I ask because in this format it is not easy to make changes...
alaios is offline   Reply With Quote
Old 08-08-2004, 05:44 PM   PM User | #4
Antoniohawk
Senior Coder

 
Join Date: Aug 2002
Location: Kansas City, Kansas
Posts: 1,518
Thanks: 0
Thanked 2 Times in 2 Posts
Antoniohawk will become famous soon enough
You can use the css pseudoclass :focus, but the support for it is pretty poor. Check out the support chart for it [here]. I probably shouldn't say that the support is poor, it's just that IE doesn't like it at all.

Last edited by Antoniohawk; 08-08-2004 at 05:48 PM..
Antoniohawk is offline   Reply With Quote
Old 08-08-2004, 07:29 PM   PM User | #5
jamescover
Regular Coder

 
Join Date: Aug 2002
Location: USA
Posts: 625
Thanks: 0
Thanked 0 Times in 0 Posts
jamescover is an unknown quantity at this point
You want this:

Quote:
onclick="this.style.backgroundColor='red'"
(Background color)


or this:

onclick="this.style.color='red'" (text color)



-james
__________________
"God so loved the world that he gave his only begotten son, so that whosoever believed in him would not perish, but have everlasting life. For God did not send his son into the world to condemn the world, but so that through him the world might be saved. "
jamescover is offline   Reply With Quote
Old 08-08-2004, 09:46 PM   PM User | #6
JohnKrutsch
Regular Coder

 
Join Date: Jun 2002
Location: The Planet Earth Code Poet: True
Posts: 282
Thanks: 0
Thanked 1 Time in 1 Post
JohnKrutsch is an unknown quantity at this point
Here is an example of how you can control the appearance of a textarea using CSS and JavaScript event handlers:

Code:
<style>

.txt_red{
	background-color:red;
	color:white;
}

.txt_blue{
	background-color:blue;
	color:yellow;
}
</style>

<textarea class="txt_blue" onfocus="this.className='txt_red'" onblur="this.className='txt_blue'" cols="30" rows="7">The style of this text area is dynamically controlled</textarea>
JohnKrutsch is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:35 PM.


Advertisement
Log in to turn off these ads.