Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-27-2005, 02:36 PM   PM User | #1
ottus
New to the CF scene

 
Join Date: Dec 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
ottus is an unknown quantity at this point
how to run an event-triggered function from inside a HTML tag?

Hello,
when I call my "moveObject" function by an onMouseUp event handler like this:

Code:
<script>
document.onmouseup = function (e) {
moveObject(e,testTable);
};
</script>
everything works fine. But I would like to call that function not by clicking anywhere in the document, but by clicking on a table clell. I used this:
Code:
...<td onMouseUp="moveObject(e,testTable)">My text</td>...
This unfortunately doesn't work. Can You see the error??

Thanx Kozelnik
ottus is offline   Reply With Quote
Old 12-27-2005, 04:36 PM   PM User | #2
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
Quote:
everything works fine
not for all browsers, anyway

What is, in fact, yout final goal? You want do attach dynamically an event to an object?
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline   Reply With Quote
Old 12-28-2005, 12:15 AM   PM User | #3
ottus
New to the CF scene

 
Join Date: Dec 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
ottus is an unknown quantity at this point
Yes. I want my function "moveObject" to be executed by clicking on a specific cell in a table. The function moves another table to the same position as the mouse cursor. The function script is:
Code:
function moveObject(e,object) {
	object.style.position = "absolute";
	object.style.top = e.pageY;
	object.style.left = e.pageX;
};
ottus is offline   Reply With Quote
Old 12-28-2005, 01:01 AM   PM User | #4
jkd
Senior Coder

 
jkd's Avatar
 
Join Date: May 2002
Location: metro DC
Posts: 3,163
Thanks: 1
Thanked 18 Times in 18 Posts
jkd will become famous soon enough
onclick="moveObject(event, testTable)"
__________________
jasonkarldavis.com
jkd is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:09 PM.


Advertisement
Log in to turn off these ads.