/    Sign up×
Community /Pin to ProfileBookmark

needing some advanced help with ondblclick

ok here is the webpage: [url]http://www.s2web.net/toggle4.php[/url]

the first colum is an image that acts like a radio button. What I need to do is 2 things, have a function that when you click in a table row, it also affects the image which is like a radio button as well. Basically a script that whe you selct a row, instead of highlighting that row, it does the image swap thing that it does already to show which row you are choosing. It works for the image right now, but I have no idea to make it so that the table row affects the image as well.

I’m no Javascript master, so of course what I’ve done so far is a frankenstein monster creation.

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisJun 30.2006 — You are kind of chasing your tail. Since you are handling the onclick event, you will never see the ondblclick event. From Microsoft (http://msdn.microsoft.com/workshop/author/dhtml/reference/events/onclick.asp):
If the user double-clicks the left mouse button in a control, an ondblclick event occurs immediately after the onclick event.[/quote]
Further (http://msdn.microsoft.com/workshop/author/dhtml/reference/events/ondblclick.asp):
The order of events leading to the ondblclick event is onmousedown, onmouseup, onclick, onmouseup, and then ondblclick. Actions associated with any of these events are executed when the ondblclick event fires.[/quote]
There was also some talk of the object needing to still have focus for an ondblclick to occur. Using the alert() in your script, the object loses focus, and all further events are cancelled.
Copy linkTweet thisAlerts:
@s2webmasterauthorJun 30.2006 — Gil, you are obviously very knowledgable in the art of Javascript, and I am not at all. I'm not sure what your saying, your explanation is a bit too textbook for me. I realize I am making somne mistakes, but what I am trying to accomplish can be done somehow. I have never not been able to solve a problem before, just the way you solve it and how long it takes to do it.
Copy linkTweet thisAlerts:
@gil_davisJun 30.2006 — Sorry, I wasn't much actual help.

You would need to understand complex event handling (also called "bubbling"). It is not a simple subject. You would be better off not trying to use both click and dblclick on the same object. You cannot wait inside the click event to see if the user is going to click again. It makes dblclick very hard to use.

I would suggest re-thinking your scheme. Maybe there is another way to do it without the dblclick. You can use click modifiers like "shift-click" and "ctrl-click" fairly easily because the keys are available to you in the event object. You could have one behaviour for regular click and another behaviour if the shift-key was pressed with the click, and a third if the ctrl-key was pressed. Look at http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/obj_event.asp for all the things you can get from the event object.
Copy linkTweet thisAlerts:
@phpnoviceJun 30.2006 — I have done this by setting a timer in the [b]onclick[/b] event, which can be cancelled by the [b]ondblclick[/b] -- if that event ends up firing. If the [b]ondblclick[/b] event doesn't fire, then the timer ends up firing the code that would have originally been associated with the [b]onclick[/b] event. Of course, this code has now been moved to its own function because of the [b]ondblclick[/b] involvement.

Now, is that as clear as mud? ?

You and I go back more than four years, Gilbert. ?
Copy linkTweet thisAlerts:
@gil_davisJul 03.2006 — You and I go back more than four years, Gilbert. ?[/QUOTE]
Yep, back to the original forum, where you could actually post examples in the page that would function! ?
Copy linkTweet thisAlerts:
@phpnoviceJul 03.2006 — He, he, he, but if you're weren't *very* careful, you ended up with a thread that couldn't be edited or used anymore. ?
×

Success!

Help @s2webmaster spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...