473,320 Members | 1,957 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,320 software developers and data experts.

Object Expected error using TD element

hi,

I'm trying to script a simple class change and it isn't working. when
I script it into the event handler of the tag it works fine, however,
I want more to happen with it in the long run than just changing the
class of the td element.

this is what I have in the script tags:

function.doMouseOver(elm)
{
elm.className='MouseOver';
{

I even tried passing nothing to the function and have it display an
alert window to test and it wouldn't even do that.

here's the tag and the event handler:

<td id="ticket5" class="unClicked" onMouseOver="doMouseOver(this);"
onMouseOut="this.className='unClicked';"
onClick="this.className='Clicked';">

when I used "this.className='MouseOver'" in the event handler, it
worked. whenever I try to call any function it gives object expected.

I also tried not passing anything and using "this" in the function
instead of the reference.

what am I doing wrong?

let me know if you need anymore information.

May 28 '07 #1
2 1774
On May 28, 2:37 pm, snowburnt <snowbu...@gmail.comwrote:
hi,

I'm trying to script a simple class change and it isn't working. when
I script it into the event handler of the tag it works fine, however,
I want more to happen with it in the long run than just changing the
class of the td element.

this is what I have in the script tags:

function.doMouseOver(elm)
{
elm.className='MouseOver';
{

I even tried passing nothing to the function and have it display an
alert window to test and it wouldn't even do that.

here's the tag and the event handler:

<td id="ticket5" class="unClicked" onMouseOver="doMouseOver(this);"
onMouseOut="this.className='unClicked';"
onClick="this.className='Clicked';">

when I used "this.className='MouseOver'" in the event handler, it
worked. whenever I try to call any function it gives object expected.

I also tried not passing anything and using "this" in the function
instead of the reference.

what am I doing wrong?

let me know if you need anymore information.
that second '{' (line 4 of the function) isn't in the code is it? :)

May 28 '07 #2
snowburnt wrote:
I'm trying to script a simple class change and it isn't
working. when I script it into the event handler of the
tag it works fine, however, I want more to happen with
it in the long run than just changing the class of the
td element.

this is what I have in the script tags:

function.doMouseOver(elm)
{
elm.className='MouseOver';
{

I even tried passing nothing to the function and have
it display an alert window to test and it wouldn't even
do that.

here's the tag and the event handler:

<td id="ticket5" class="unClicked"
onMouseOver="doMouseOver(this);"
onMouseOut="this.className='unClicked';"
onClick="this.className='Clicked';">
Two syntax errors:
- the last '{' should be a '}'
- 'function.doMouseOver' should be 'function doMouseOver'

One bad habit:
- 'MouseOver' sounds like a property name rather than a class

So:

<html>
<head>
<title>My web page</title>
<style type="text/css">
.green { background-color:green }
</style>
<script type="text/javascript">
function doMouseOver(elm) {
elm.className='green'
}
</script>
</head>
<body>
<table border="1">
<tr>
<td onClick="doMouseOver(this);">click me</td>
</tr>
</table>
</body>
</html>

Hope this helps,

--
Bart

May 28 '07 #3

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

Similar topics

4
by: Bill | last post by:
I call a function in my .js file like this: onClick="location.href='blank.html' + generateSearchStringFromForm('section')" where section is the name of my form. The function is defined as...
4
by: Kiyomi | last post by:
Hello, I am trying to replace my alert message box with a popup page. In my page behind,
26
by: yb | last post by:
Hi, Is there a standard for the global 'window' object in browsers? For example, it supports methods such as setInterval and clearInterval, and several others. I know that w3c standardized...
12
by: Andrew Poulos | last post by:
With the following code I can't understand why this.num keeps incrementing each time I create a new instance of Foo. For each instance I'm expecting this.num to alert as 1 but keeps incrementing. ...
2
by: Ralph | last post by:
Hi I don't understand why it's not working: function schedule(imTop){ this.tdImagesTop = imTop; } schedule.prototype.selectEl = function() { alert(this.tdImagesTop);
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: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
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)...
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.