473,395 Members | 2,783 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,395 software developers and data experts.

Newbee Question

Hi, I'm just learning this new scripting language.

I have created a little script (see below). The HTML builds a table and one
of the cells has a OnMouseOver parameter which I have set to my "Hello"
function. How do I reference the cell used to trigger "Hello". For
example, can I change the background color of the cells as the mouse passes
over them?

<TD onMouseOver="hello()">test</TD>

Within hello, how do I reference the TD cell that triggered hello?

I hope this makes sense.

Thanks in Advance!

Paul
Minneapolis


<html>
<head>
<title>CSS - Example 1</title>
<SCRIPT LANGUAGE="JavaScript">
<!-- // Activate cloak
function hello()
/************************************************** ***************
`description`
11/9/2003 12:37PM
************************************************** ***************/
{

alert("test");
/* how do I reference the cell that invoked this script" */

} // hello()
// Deactivate cloak -->
</SCRIPT>
<link rel=stylesheet type="text/css"
href="css1.css"
title="Example 1">
</head>
<body>
<h1>Test H1</h1>
<table align="center" class=test>
<TR>
<TD onMouseOver="hello()">test</TD>
<TD>test</TD>
</TR>
<TR>
<TD>test</TD>
<TD>test</TD>
</TR>
</table>
<h1>Test H1</h1>
</body>
</html>

Jul 20 '05 #1
6 1817
VK
<td onMouseOver="doWhatYouWantWith(this)"></td>

function doWhatYouWantWith(obj) {
obj.style.backgroundColor = myColor;
// and so on
}
Jul 20 '05 #2

"Paul Baker" <pb******@mindspring.com> wrote in message
news:bo*******@enews2.newsguy.com...
Hi, I'm just learning this new scripting language.

I have created a little script (see below). The HTML builds a table and one of the cells has a OnMouseOver parameter which I have set to my "Hello"
function. How do I reference the cell used to trigger "Hello". For
example, can I change the background color of the cells as the mouse passes over them?


Depending on the browser, event handlers either recieve an event object as a
parameter (Mozilla, DOM event model compliant browsers), or can access the
event object on the window object (IE).

Here's an example

function hello(event)
{

if(typeof event == "undefined")
{
event = window.event;
}

//event.target stores the object reference for the node that was the source
of the event for the DOM event model.
//event.srcElement stores the object reference for the node that was the
source of the event for IE
var src = event.target || event.srcElement;
}

Matt
Jul 20 '05 #3
Paul Baker wrote on 09 nov 2003 in comp.lang.javascript:
<TD onMouseOver="hello()">test</TD>

Within hello, how do I reference the TD cell that triggered hello?


....
<TD id="myidea" onMouseOver="hello(this)">test</TD>
....

<script>
function hello(x){
alert(x.id)
alert(x.innerText) // IE
}
</script>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #4
Hi again,

Yes, I can see how "this" could be used. I can display parameters
associated with "this" but is it possible to actually change the parameters
dynamically. Like my example, can I change the background color of the cells
as the mouse passes over them?

Thank again!

Paul


"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
Paul Baker wrote on 09 nov 2003 in comp.lang.javascript:
<TD onMouseOver="hello()">test</TD>

Within hello, how do I reference the TD cell that triggered hello?


...
<TD id="myidea" onMouseOver="hello(this)">test</TD>
...

<script>
function hello(x){
alert(x.id)
alert(x.innerText) // IE
}
</script>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Jul 20 '05 #5
Paul Baker wrote on 10 nov 2003 in comp.lang.javascript:
Yes, I can see how "this" could be used. I can display parameters
associated with "this" but is it possible to actually change the
parameters dynamically. Like my example, can I change the background
color of the cells as the mouse passes over them?

Sure, why don't you try?

You will have to read up on css, perhaps

<TD onMouseOver="hello(this)">test</TD>
...

<script>
function hello(x){
x.style.backgroundColor = "yellow"
}
</script>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #6
Thanks...

"Evertjan." <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
Paul Baker wrote on 10 nov 2003 in comp.lang.javascript:
Yes, I can see how "this" could be used. I can display parameters
associated with "this" but is it possible to actually change the
parameters dynamically. Like my example, can I change the background
color of the cells as the mouse passes over them?


Sure, why don't you try?

You will have to read up on css, perhaps

<TD onMouseOver="hello(this)">test</TD>
...

<script>
function hello(x){


x.style.backgroundColor = "yellow"
}
</script>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Jul 20 '05 #7

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

Similar topics

3
by: Newbee | last post by:
Hi ! Let's say that this is the folder on the server: /web/firstDir/secondDir/images/image.gif where i have stored my pictures. I have tryed with apsolute and relative paths but i can't display...
2
by: Newbee Adam | last post by:
some said that .NET app can run on any program where rutime exists. What is "runtime" in this sense? will I have to install runtime or .net framework or .NET support on an xp machine for a...
4
by: PerryC | last post by:
All, 1. Do the following codes seem ok? 2. If so, then how do I pull the value of YOE1 and YOE2 into my report? (to do some further calculations) ...
2
by: Martin Hvidberg | last post by:
Dear list I have found a declaration like this: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #include <math.h> #include "ectemp.h"
0
by: valmir cinquini | last post by:
i'm developing a faq session of our website and I'm facing some problems handling xml files and DataSet relations First off all, here's the structure of my xml file: <?xml version="1.0"?>...
9
by: EMW | last post by:
I have created a page in aspx and after a click on a button, a new page should open. How is this possible? I tried it doing it like in vb.NET with opening a new form, but it doesn't work. rg,...
1
by: Mark Fink | last post by:
Hi there, unfortunately I am new to Jython and my "Jython Essentials" book is still in the mail. I looked into the Jython API Doc but could not find the information. I am porting a Python...
2
by: IchBin | last post by:
I am trying to clean up my code. I have run it through tidy and now have the code below. The problem is that anytime I select a radio button I get the following error: Forbidden You don't have...
2
by: Mel | last post by:
I have a selection box with 3 values. what i need is to pass 3 urls to a function that has a switch statement and based on the selection index goes on one of the tree urls. Question is how do i...
0
by: Martin Arvidsson, Visual Systems AB | last post by:
Hi! I have a couple of newbee questions. I have a .aspx page with a couple of TextBoxes and a submit button. Now... When i press the submitbutton i want the data in the TextBoxes to be...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.