473,378 Members | 1,495 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

changing a textarea's bgcolor

Markus
6,050 Expert 4TB
If you take a look at the textarea for commenting on this page you'll see my desire.

When hovering over the textarea the bgcolor changes, but once the textarea is clicked it maintains this new color until the area loses focus.

What's going on guys?
May 18 '08 #1
10 8644
harshmaul
490 Expert 256MB
wasup markus!!!

CSS follows...
Expand|Select|Wrap|Line Numbers
  1. textarea:hover{
  2.     background:#ffc;
  3.     cursor:text;
  4. }
May 19 '08 #2
Markus
6,050 Expert 4TB
wasup markus!!!

CSS follows...
Expand|Select|Wrap|Line Numbers
  1. textarea:hover{
  2.     background:#ffc;
  3.     cursor:text;
  4. }
SUP DAWG!

I was aware of this.

But surely on mouseout the bgcolor reverts?
May 19 '08 #3
Death Slaught
1,137 1GB
You can probably just use JavaScript it seems simple enough. On click change the background color and on blur change it back.

Thanks,
{\_/}
(' . ')
(")[DEATH](")
(")(")

PS - When my computer stops lagging I may try and do it and then post the code, but before I post it I want to see you try it. ^_^
May 20 '08 #4
hsriat
1,654 Expert 1GB
oohh... I caught Mark posting same question in 2 forums! :D

I hope Mark got his answer by now. :)
May 20 '08 #5
Death Slaught
1,137 1GB
lol and he still hasn't gotten a working example for IE6!

Thanks,
{\_/}
(' . ')
(")[DEATH](")
(")(")
May 20 '08 #6
hsriat
1,654 Expert 1GB
ooohhh!! really?... he never said that...

If he needs a JavaScript solution, then here it is...[html]<style type="text/css">
textarea {
background-color:#ffffff;
border:#445588 solid 1px;
}
textarea.bright {
background-color:#ccccff;
border:#000000 solid 1px;
}
</style>
<textarea name="markstext"
cols="100"
rows="5"
onmouseover="if (this.title!='The title ') {this.className='bright';this.title='The title';}"
onfocus="this.className='bright';this.title='The title ';"
onmouseout="if (this.title!='The title ') {this.className='';this.title='';}"
onblur="this.className='';this.title='';"
title="">
</textarea>
[/html]
If you want to provide a title say "My textarea" to the text area, just replace "The title" in the code it with, DON'T remove the space after the title!.

This will miss just one case. Le'me see if Mark can find that.

But still, I do recommend to use the CSS's hover and focus. And provide strict doctype if possible to validate that.

Regards
May 20 '08 #7
hsriat
1,654 Expert 1GB
And this is better...[html]<style type="text/css">
textarea {
background-color:#ffffff;
border:#445588 solid 1px;
}
textarea.bright {
background-color:#ccccff;
border:#445588 solid 1px;
}
textarea.bright1 {
background-color:#ccccff;
border:#445588 solid 1px;
}
</style>
<textarea name="markstext"
onmouseover="if (this.className!='bright1') this.className='bright';"
onfocus="this.className='bright1';"
onmouseout="if (this.className!='bright1') this.className='';"
onblur="this.className='';"
title="whatever title">
</textarea>[/html]
May 21 '08 #8
harshmaul
490 Expert 256MB
WOW! you guys were up throughout the night!!! damn my time zone!
May 21 '08 #9
hsriat
1,654 Expert 1GB
WOW! you guys were up throughout the night!!! damn my time zone!
It was your evening at the time. Don't damn your time zone.

My side it was 3:00AM :D, and 12 hours ahead DS.
May 21 '08 #10
Markus
6,050 Expert 4TB
Aren't you guys nice!

I completely forgot about this...

Haha, I also apologise for double posting :|

I had a slip in concentration!

Anyways, seems both threads have had a decent discussion, and plenty of suggestions. Time to have a read!

Thanks again, my lovelies.
May 21 '08 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: John D | last post by:
I am trying to change the background colour of either a div or a textarea with javascript, but am having problems. I have passed a hex colour value in the variable hval, and with the following...
12
by: dan.vendel | last post by:
Hi, I know nothing about javascript, but quite a lot about regulat html and CSS. Have bumped into a problem that people in this fine congregation perhaps can help me with. I'm making a...
12
by: GaryDean | last post by:
In the original post I failed so indicate that I am using framework 1.1....... I need to be able to change the background color of a page from code. I found an answer to this question in...
15
by: phillip.s.powell | last post by:
<style> div div table tr td a.navbar, div div table tr td font {display: none;} </style> <div class="navigationbar" style="background-color:Black; position: absolute; left:50%; top:127px;...
4
by: Keith Bentrup | last post by:
Hi all, I wrote a simple search function to find text in a textarea where not all the text is visible (ie. the text box displays 10 lines but there may be more than 1000 lines to search). I can...
0
by: lawrenceS59 | last post by:
Hi all, I'm fairly new to web development so bare with me. The html page that i've created isn't working and i can't figure out why. I'm guessing there are some rules that need to be...
0
by: lawrenceS59 | last post by:
Hi all, I'm fairly new to web development so bare with me. The html page that i've created isn't working and i can't figure out why. I'm guessing there are some rules that need to be followed...
2
by: Lovens Weche | last post by:
I'm trying to set the "readonly" attribute of a "textarea" element this way: --------------------------------- <script type="text/javascript"> ***snip***
9
Markus
by: Markus | last post by:
If you take a look at the textarea for commenting on this page you'll see my desire. When hovering over the textarea the bgcolor changes, but once the textarea is clicked it maintains this new...
15
by: globalrev | last post by:
i have a translator-program for the robbers language. i want the user to input into the topwindow and then display the encryption or decryption in the bottom window. i am currently trying to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.