473,785 Members | 2,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

change background color on hover or select

I have a table with a form consisting of several checkboxes and I'm
wondering if its possible to change the table row background color on
mouseover or hover and make it stay that color when the checkbox in that row
is selected?
Poko
Sep 25 '05 #1
13 12534
Gary said the following on 9/25/2005 3:18 AM:
I have a table with a form consisting of several checkboxes and I'm
wondering if its possible to change the table row background color on
mouseover or hover and make it stay that color when the checkbox in that row
is selected?


Yes, it is very possible and quite simple actually. Search the archives,
give it your best try, and post back with some code and/or a URL to your
efforts. Or, did you expect someone to write the entire thing from scratch?

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Sep 25 '05 #2
Randy Webb wrote:
Gary said the following on 9/25/2005 3:18 AM:
I have a table with a form consisting of several checkboxes and I'm
wondering if its possible to change the table row background color on
mouseover or hover and make it stay that color when the checkbox in
that row is selected?


Yes, it is very possible and quite simple actually. Search the
archives, give it your best try, and post back with some code and/or
a URL to your efforts. Or, did you expect someone to write the entire
thing from scratch?


:) Point taken, thank you for your response Randy
poko
Sep 25 '05 #3
ASM
Gary a écrit :
I have a table with a form consisting of several checkboxes and I'm
wondering if its possible to change the table row background color on
mouseover or hover and make it stay that color when the checkbox in that row
is selected?
Poko


No, you have a form containing a table
(table can't contain a form)
(table can contain elements of a form)

see that :
http://perso.wanadoo.fr/stephane.mor...ht_rows_en.htm
<html><form><ta ble border=1 cellspacing=0>
<tr>
<td>
<input type=checkbox onclick="highLg ht(this)">
</td>
<td>blah</td><td>blah</td><td>blah</td>
</tr>
<tr>
<td>
<input type=checkbox onclick="highLg ht(this)">
</td>
<td>blah</td><td>blah</td><td>blah</td>
</tr>
</table></form>
<script type="text/javascript">
function highLght(chckbo x) {
var rw = chckbox.parentN ode.parentNode;
rw.className = (chckbox.checke d)? 'backCol' : '';
}
</script>
<style type="text/css">
..backCol { background-color: yellow }
</style>
</html>
--
Stephane Moriaux et son [moins] vieux Mac
Sep 25 '05 #4
ASM
Randy Webb a écrit :
Or, did you expect someone to write the entire thing from scratch?


Sorry ...

--
Stephane Moriaux et son [moins] vieux Mac
Sep 25 '05 #5
ASM wrote:
Gary a écrit :
I have a table with a form consisting of several checkboxes and I'm
wondering if its possible to change the table row background color on
mouseover or hover and make it stay that color when the checkbox in
that row is selected?
Poko
No, you have a form containing a table
(table can't contain a form)
(table can contain elements of a form)


:) u da man!
But of course you are right.

see that :
http://perso.wanadoo.fr/stephane.mor...ht_rows_en.htm merci beaucoup ASM, I'm afraid to say its slightly above my abilities but it
gives me something to work with :)
poko

<html><form><ta ble border=1 cellspacing=0>
<tr>
<td>
<input type=checkbox onclick="highLg ht(this)">
</td>
<td>blah</td><td>blah</td><td>blah</td>
</tr>
<tr>
<td>
<input type=checkbox onclick="highLg ht(this)">
</td>
<td>blah</td><td>blah</td><td>blah</td>
</tr>
</table></form>
<script type="text/javascript">
function highLght(chckbo x) {
var rw = chckbox.parentN ode.parentNode;
rw.className = (chckbox.checke d)? 'backCol' : '';
}
</script>
<style type="text/css">
.backCol { background-color: yellow }
</style>
</html>

Sep 25 '05 #6
ASM wrote on 25 sep 2005 in comp.lang.javas cript:
Gary a écrit :
I have a table with a form consisting of several checkboxes and I'm
wondering if its possible to change the table row background color on
mouseover or hover and make it stay that color when the checkbox in
that row is selected?
Poko
No, you have a form containing a table
(table can't contain a form)
(table can contain elements of a form)

see that :
http://perso.wanadoo.fr/stephane.mor...hlight_rows_en.
htm
<html><form><ta ble border=1 cellspacing=0>

[..] </html>


This will hover and will be clickable along the whole <tr>:

<html>

<style type="text/css">
..backCol { background-color:yellow;}
..hoverbackCol { background-color:blue;colo r:white;}
</style>

<script type="text/javascript">

function ifhover(x,istru e) {
if (istrue) bgsave=x.classN ame
x.className = (istrue)?'hover backCol':
(x.firstChild.f irstChild.check ed)? 'backCol' : '';
}

function clickhighLght(x ) {
x.firstChild.fi rstChild.checke d =
!x.firstChild.f irstChild.check ed;
x.className =
(x.firstChild.f irstChild.check ed)? 'backCol' : '';
}

function highLght(chckbo x) {
clickhighLght(c hckbox.parentNo de.parentNode);
}
</script>

<form>
<table border=1 cellspacing=0>

<tr onclick="clickh ighLght(this)"
onmouseover="if hover(this,true )"
onmouseout="ifh over(this, false)">
<td>
<input type=checkbox onclick="highLg ht(this)">
</td>
<td>blah</td><td>blah</td><td>blah</td>
</tr>

<tr onclick="clickh ighLght(this)"
onmouseover="if hover(this,true )"
onmouseout="ifh over(this, false)">
<td>
<input type=checkbox onclick="highLg ht(this)">
</td>
<td>blah</td><td>blah</td><td>blah</td>
</tr>

</table>
</form>
</html>

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Sep 25 '05 #7
Evertjan. wrote:
ASM wrote on 25 sep 2005 in comp.lang.javas cript:
Gary a écrit :
I have a table with a form consisting of several checkboxes and I'm
wondering if its possible to change the table row background color
on mouseover or hover and make it stay that color when the checkbox
in that row is selected?
Poko


No, you have a form containing a table
(table can't contain a form)
(table can contain elements of a form)

see that :
http://perso.wanadoo.fr/stephane.mor...hlight_rows_en.
htm
<html><form><ta ble border=1 cellspacing=0>

[..]
</html>


This will hover and will be clickable along the whole <tr>:

<html>

<style type="text/css">
.backCol { background-color:yellow;}
.hoverbackCol { background-color:blue;colo r:white;}
</style>

<script type="text/javascript">

function ifhover(x,istru e) {
if (istrue) bgsave=x.classN ame
x.className = (istrue)?'hover backCol':
(x.firstChild.f irstChild.check ed)? 'backCol' : '';
}

function clickhighLght(x ) {
x.firstChild.fi rstChild.checke d =
!x.firstChild.f irstChild.check ed;
x.className =
(x.firstChild.f irstChild.check ed)? 'backCol' : '';
}

function highLght(chckbo x) {
clickhighLght(c hckbox.parentNo de.parentNode);
}
</script>

<form>
<table border=1 cellspacing=0>

<tr onclick="clickh ighLght(this)"
onmouseover="if hover(this,true )"
onmouseout="ifh over(this, false)">
<td>
<input type=checkbox onclick="highLg ht(this)">
</td>
<td>blah</td><td>blah</td><td>blah</td>
</tr>

<tr onclick="clickh ighLght(this)"
onmouseover="if hover(this,true )"
onmouseout="ifh over(this, false)">
<td>
<input type=checkbox onclick="highLg ht(this)">
</td>
<td>blah</td><td>blah</td><td>blah</td>
</tr>

</table>
</form>
</html>


Evertjan!
thats exactly what I was hoping for......thank you!
poko
Sep 25 '05 #8
ASM wrote in message news:43******** *************** @news.wanadoo.f r...
Gary a écrit :
I have a table with a form consisting of several checkboxes and I'm
wondering if its possible to change the table row background color on
mouseover or hover and make it stay that color when the checkbox in that row
is selected?
Poko
see that :
http://perso.wanadoo.fr/stephane.mor...ht_rows_en.htm
A very long long time ago (about 4 years) I managed to put together the
following "tables" and javascript (sorry about all the junk in there):
http://www.geocities.com/peg_seti/gr...tm#country-tbl
I have no idea on what browsers it worked, but it still does in FF ;-)
The idea was to be able to move the mouse over a row in any of the last
four tables and it would highlight the respective row in the other three.

I did validate it once , but as I said, that was eons of years ago.
So ignore the align="absbotto m" errors if you /have/ to validate it ;-)
Thank FrontPage of Micro$oft for that...

BTW, you say
No, you have a form containing a table
(table can't contain a form)
actually it can; not directly in the <table> tag but in <TD> and <TH>

<!ENTITY % block
"P | %heading; | %list; | %preformatted; | DL | DIV | CENTER |
NOSCRIPT | NOFRAMES | BLOCKQUOTE | FORM | ISINDEX | HR |
TABLE | FIELDSET | ADDRESS">
---> ^^^^^ ^^^^

<!ENTITY % flow "%block; | %inline;">
---> ^^^^^^^
<!ELEMENT TABLE - -
(CAPTION?, (COL*|COLGROUP* ), THEAD?, TFOOT?, TBODY+)>

<!ELEMENT (TH|TD) - O (%flow;)* -- table header cell, table data cell-->
---> ^^^^^^
(table can contain elements of a form)


I have both in http://www.geocities.com/peg_seti

<table>
<tr>
<td>
<form ...>
<table>
<tr>
<td>
<input ...>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>

Sep 25 '05 #9
ASM
Robi a écrit :
ASM wrote in message news:43******** *************** @news.wanadoo.f r...
see that :
http://perso.wanadoo.fr/stephane.mor...ht_rows_en.htm

A very long long time ago (about 4 years)


Do you mean I did nothing invent ?
You're right.
Sometimes, I try some idea found here or there
and I keep it to show to others if I think it can be of some interest.
(any copyright, even not my name most of the time)
I managed to put together the
following "tables" and javascript (sorry about all the junk in there):
http://www.geocities.com/peg_seti/gr...tm#country-tbl
I have no idea on what browsers it worked, but it still does in FF ;-)
Oh, I have also a little demo about that, not so elaborated than yours.
The most difficulty is to crutch IE
The idea was to be able to move the mouse over a row in any of the last
four tables and it would highlight the respective row in the other three.
For the moment I'm fighting with appendChild in a table a cloneNoded row.
That's work fine with FF, Opera and others except ... IE (of course)
I have yet to do a simplier test before coming to ask here what is wrong.
I did validate it once
Hope you will not try with my little demos ...
I didn't it.
No, you have a form containing a table
(table can't contain a form)

actually it can; not directly in the <table> tag but in <TD> and <TH>


That's what I wanted to say, in fact the form is in a td
by chance a td is part of a table :-)
(because certainly you use a table as structural tool)

By end and ... finaly the form contains a table
turned this way, I could too say the table below contains a table :-)
<table>
<tr>
<td>
<form ...>
<table>
<tr>
<td>
<input ...>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>

--
Stephane Moriaux et son [moins] vieux Mac
Sep 25 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
14778
by: David T-G | last post by:
Hi! Please be gentle; I'm new to ciwas and CSS in general, and know little to no javascript (but that might win me points here ;-) I have nine 'tab' images, with corresponding high-background versions for display under hover, which I would like to control via CSS. When on a page, the tab should be just an image rather than a link with hover sensing, so that is probably easy to just use <img> rather than <div> there.
2
21341
by: carramba | last post by:
Hi! is it possible to change "selector" color in drop-down list? <select name="select" style="background-color: #ff0000"> <option style="background-color: #ff0000" value="1">Cony</option> <option style="background-color: #ffffff" value="2">Alex</option> <option style="background-color: #0000ff" value="3">Peter</option> </select>
1
16088
by: nick | last post by:
I have the following code: <style> #item1 { DISPLAY: block; BACKGROUND: url(ProjMenuImgs/ProjBtn.gif) no-repeat 0px 0px; WIDTH: 87px; HEIGHT: 94px; } #item1:hover { background-position: 0 -92px; }
10
6013
by: Richard | last post by:
The style sheet shown below is from the suckerfish vertical menu. http://www.htmldog.com/articles/suckerfish/dropdowns/example/vertical.html I've added in a few minor changes to color code the levels. I changed the width of the first level to 8em and get an unwanted space between that and the 2nd level. I'd like their to be no gap between the levels when I change the widths. What's to change to do this? Also, I do not understand the...
11
19618
by: Yeah | last post by:
I have a multiple choice quiz where I would like to use CSS to change the color of the answers upon clicking them. I would like to present the right and wrong answers up front, rather than direct the user to a separate page with all correct answers. Do the answers have to be "links" for this to work? They have to be inactive links, because they don't actually go anywhere. They only serve the purpose of changing color whether they're...
3
3390
by: Mike Barnard | last post by:
Hi all, newbie here. Odd sounding subject but I can't describe it any better. I'm trying to teach myself a little about CSS. In a test site (not published) I am trying to use CSS to make navigation buttons. I'm using the tutorial I found at this site as a basis for it. http://www.mako4css.com/TFonts.htm
2
4541
by: chris_culley | last post by:
Hi there, I've got a gif with (highly) irregular shapes (lots of jigsaw pieces) that I want to map so that each piece is a link... The pieces are currently just a frame drawing, but as they are hovered over I want them to be coloured in. I thought the easiest way to do this would be to change the background image of the entire map (since it's a bit of a pain trying to select each piece out of the image and
1
1755
by: roN | last post by:
Hi, I have a table in which I would like to change the background image onMouseOver. I implemented it with CSS but IE doesn't support hovers on tables, so I'd need to go via JS for IE. Can anyone give me a hint how to do this? So far it looks like: <tr> <td class="frontbar"> <a href="#"><img src="images/dot.gif" width="10"
5
4657
by: studentofknowledge | last post by:
hi guys im new to javascript and need some guidence please.. im trying to display a 400x400 pixel coloured area in the middle of a webpage that stays in the middle with a browser window resize. Within the area, i would like to display an image and some text, overriding a few words with an inline style. i would like the image to change once the mouse is placed over it. and when the mouse is removed from the image the image should...
0
9646
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9483
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10157
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10096
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9956
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8982
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7504
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5514
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.