473,287 Members | 1,419 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,287 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?

Edit. I posted this in the wrong darn forum!
May 18 '08 #1
9 2825
Atli
5,058 Expert 4TB
You can use the onMouseOver, onMouseOut, onFocus and onBlur events to do this.
You will just have to create a JavaScript variable that indicates whether the input has focus. When it does, prevent the onMouseOut event from changing the color.

Edit. I posted this in the wrong darn forum!
I'll move it over to the JavaScript forums.
May 18 '08 #2
Atli
5,058 Expert 4TB
Or better yet... The CSS :hover and :focus effects
Expand|Select|Wrap|Line Numbers
  1. textarea {
  2.     background-color: #FFFFFF;
  3. }
  4. textarea:hover, textarea:focus {
  5.     background-color: #FFFFCC;
  6. }
  7.  
Doesn't work in IE tho :(
(Grrr @ M$)
May 18 '08 #3
hsriat
1,654 Expert 1GB
Well, its still in the wrong forum :p

Use this css

Expand|Select|Wrap|Line Numbers
  1. textarea.effect, input.effect {
  2.     background-color:#eeeeff;
  3. }
  4. textarea.effect:hover, input.effect:hover,textarea.effect:focus, input.effect:focus {
  5.     background-color:#ffeeee;
  6. }
where effect is the class name of the textareas and input boxes to whom you want to apply this.


[EDIT].. I'm late.. already done by Atli :)
May 18 '08 #4
Velhari
46
Or better yet... The CSS :hover and :focus effects
Expand|Select|Wrap|Line Numbers
  1. textarea {
  2.     background-color: #FFFFFF;
  3. }
  4. textarea:hover, textarea:focus {
  5.     background-color: #FFFFCC;
  6. }
  7.  
Doesn't work in IE tho :(
(Grrr @ M$)
Hi,

This code is working in IE on Strict Mode.
May 19 '08 #5
hsriat
1,654 Expert 1GB
Hi,

This code is working in IE on Strict Mode.
Strict Mode.. .... Strict Doctype?
May 19 '08 #6
acoder
16,027 Expert Mod 8TB
Hi,

This code is working in IE on Strict Mode.
I guess that would be IE7.
May 20 '08 #7
acoder
16,027 Expert Mod 8TB
You can use the onMouseOver, onMouseOut, onFocus and onBlur events to do this.
You will just have to create a JavaScript variable that indicates whether the input has focus. When it does, prevent the onMouseOut event from changing the color.
CSS :hover pseudo-classes are not supported by IE7 unless a doctype is provided, so you will need to use JavaScript to achieve this (if you also need to support IE6).
May 20 '08 #8
Markus
6,050 Expert 4TB
Thanks for all the responses guys!

They all, at a glance, are what I'm looking for.

Wasn't a major thing, just a query.

:)
May 21 '08 #9
This CSS code worked fine for me too in Chrome :)
Feb 16 '12 #10

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...
10
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...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.