472,990 Members | 3,034 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How to change table cell text on <TD> mouseover

I'm not a JavaScript programmer...but I'm trying to put together a simple
menu system for a new website and need a little help.

I have the following script:

<SCRIPT language=javascript>
<!-- Hide JavaScript from Java-Impaired Browsers
function NavRollOver(oTd) {if (!oTd.contains(event.fromElement))
{oTd.bgColor="#CC0000";}}
function NavRollOut(oTd) {if (!oTd.contains(event.toElement))
{oTd.bgColor="#FFCC00";}}
// End Hiding -->
</SCRIPT>

And the following table cell definition:

<td onmouseover="NavRollOver(this)" onmouseout="NavRollOut(this)"
height="25" bgcolor="#FFCC00">
<font face="Verdana" size="2">&nbsp; </font>
<a href="../index.htm">
<font face="Verdana" color="#000000" size="2">
<span style="text-decoration: none">Home</span></font></a></font></td>

In addition to changing the cell background color, which is working
correctly now, I need to change the font color to White and font weight to
Bold on a rollover.

Can anyone help?

Thanks in advance,

Pete
Jul 23 '05 #1
2 6079
"Pete Kipe" <pk***@corpdatasys.com> wrote in message news:<34********************@giganews.com>...
I'm not a JavaScript programmer...but I'm trying to put together a simple
menu system for a new website and need a little help. .... In addition to changing the cell background color, which is working
correctly now, I need to change the font color to White and font weight to
Bold on a rollover.

Can anyone help?

Here is what I wrote up. Hope it helps.

I find it easier to work the css for the part of the page I will be
changing dynamically. It should still work with the font stuff, but
Javascript is in css. Notice how the css name font-weight change to
fontWeight. That is if the css attribute contains a -, you delete the
dash and change the next character to a uppercase character. (Change
from Cobol style variables to C style.)

Working with CSS requires you to get used to a new syntax. Once you
get the coding correct, it is easy to copy the coding via the class
tag.

Some parts of the code looked IE only. I am not familiar with events
anyway beyaond what you see in this code. I was not sure what this
code did. It didn't seem to be needed based on what you wanted to do.

You do not need all the <!-- stuff.

Robert
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>change table colors</title>

<style type="text/css">
..tableText {"text-decoration: none;
font: Verdana;
color: #000000
font-size: small"}
</style>
<SCRIPT type="text/javascript">
function NavRollOver(oTd,spanId)
{

/* Mystery to me. Looks like some IE thing.
Just as easier to code it to work for all
web broswers.
if (!oTd.contains(event.fromElement))
{
oTd.bgColor="#CC0000";
}

end of IE stuff. */

oTd.style.backgroundColor = "red";

var spanElem = document.getElementById(spanId);
spanElem.style.color = "white";
spanElem.style.fontStyle = "italic";
spanElem.style.fontWeight = "bolder";

}

function NavRollOut(oTd,spanId)
{
oTd.style.backgroundColor = "#FFCC00";

var spanElem = document.getElementById(spanId);
spanElem.style.color = "black";
spanElem.style.fontStyle = "normal";
spanElem.style.fontWeight = "normal";

}

</SCRIPT>
</head>
<body>
<p>And the following table cell definition:</p>
<table>
<tr>
<td onmouseover='NavRollOver(this,"changetext");'
onmouseout='NavRollOut(this,"changetext")'
height="25"
style="background-color: #FFCC00">
&nbsp;
<a href="../index.htm">
<span class="tableText" id="changetext">Home</span></a>&nbsp;
</td>
</tr>

</table>
</body>
Jul 23 '05 #2
"Pete Kipe" <pk***@corpdatasys.com> wrote in message news:<34********************@giganews.com>...
I'm not a JavaScript programmer...but I'm trying to put together a simple
menu system for a new website and need a little help. .... In addition to changing the cell background color, which is working
correctly now, I need to change the font color to White and font weight to
Bold on a rollover.

Can anyone help?

Thanks in advance,


And now that I think of it and I coded up all the javascript, you
should be able to do what you want with the css hover tag.

I think you can search this form for examples.

Robert
Jul 23 '05 #3

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

Similar topics

4
by: A Web Master | last post by:
As a mean of not having to use Framesets/Frames with all the bad side effects/workarounds that come with them, I want to know if it is possible to code a scrolling veritcal bar into a table <TD> ?...
1
by: christian9997 | last post by:
Hi I was trying to create a page where a SubMenu would appear when the user moved the mouse over an item of a Menu (= Table Cell <TD>). Unfortunately there seems to be a problem; the onMouseOver...
1
by: Stan Brown | last post by:
In looking over my style sheet http://www.acad.sunytccc.edu/instruct/sbrown/screen.css I see that I have identical fonts and colors set on table and td elements. Is there any reason to do this,...
1
by: prefersgolfing | last post by:
I'm not using Master Pages, yet I'd like to display the contents of an HTML page within a <table><tr><td> on a .aspx. I have a lengthy guide already paginated in html. I'd like to embed the...
4
by: dropdeadster | last post by:
Trying to line up a tic-tac-toe board type grid of images using style= tags to <img inside a table TD but it's not working, I get more like a set of steps, can I get an explanation of what's wrong...
4
by: Jason | last post by:
Is that possible? How? <td > <asp:Label ID="StartDateLabel" runat="server" Text="Start Date:"> <asp:imagebutton ID="Imagebutton1" width=18 Height=18 CommandName=SetDate imageUrl="../cal.jpg"...
7
by: Xiaoyan | last post by:
Hi,everyone: I have a problem now. I can't get the information between the <tr><td> and </td></tr>. for example: I use this regular expression can't get it, I don't know why....
2
by: markszlazak | last post by:
I'm a relatively slow response of table cells changing their background color with mouseover/our in IE6 (Win 2K) but the response is fine (fast) in Firefox. Why? The code is below. Sorry about the...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.