Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
mouse over/out events with elements inside a div
Old 07-27-2008, 06:29 PM mouse over/out events with elements inside a div
Novice Talker

Posts: 13
Trades: 0
hi all!

i'm adding currency converter to my site. the idea is at the page load it will display some default currency rate (say, 1 € = 1.56 $ ), but when user moves mouse over that block, it will turn into four controls where user can enter numbers and select currencies he/she wants. and when the mouse is out, it will hide controls, and turn back to displaying the rate/conversion results.

i did it and it works (i'll post some code below), but I have a problem where the controls flicker (as if quickly hide then redisplay) when the mouse moves over the borders of controls (input & select). I have a "container" DIV, for which I have mouseover and mouseout, and inside I have spans for display, and input/select controls for calculator. using JS i show/hide whichever is appropriate. this happens only in IE & Opera, but thats 90% of my visitors. ok in FF.

here's small pieces of my code:
Code:
<div id="barCurrency" onmouseover="converter('over')" onmouseout="converter('out')">
    <span id="dispAmmountFrom">1</span> <span id="dispCurFrom">USD</span>
    <input id="ammountFrom" onkeyup="UpdateAmmountTo()" style="display:none" />
    <select id="curFrom" onchange="UpdateAmmountTo()" style="display:none">
    <option value="usd">$</option>
    <option value="eur">€</option></select>
    =
    <span id="dispAmmountTo">1</span> <span id="dispCurTo">Sk</span>
    <select id="curTo" onchange="UpdateAmmountTo()" style="display:none">
    <option value="usd">$</option>
    <option value="eur">€</option></select>
</div>
Code:
function converterMouse(overout) {
    if (overout == 'over') {
        converterMouseOver = true;
        showConvertForm();
    }
    else {
        converterMouseOver = false;
        hideConvertForm();
    }
}

function showConvertForm() {
    if (converterActive) return;

    ...

    // hideConvertForm() does the opposite
    elDispAmmountFrom.style.display = "none";
    elDispCurFrom.style.display = "none";
    elDispCurTo.style.display = "none";
    elAmmountFrom.style.display = "inline";
    elCurFrom.style.display = "inline";
    elCurTo.style.display = "inline";
    
    converterActive = true;
}
so again, when I move mouse over contols inside the barCurrency DIV it still flickrs, as if it triggers both quickly mouseout then mouseover when I go from the inside that DIV into the INPUT (which is inside the div as well!)...

what can I do to make sure I only get single mouse over for the DIV no matter what's inside of it? I tried adding fieldset inside, tried giving it mouseover/out, tried wrapping it in another DIV moving mouse events to it - always the same story
flamey is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-28-2008, 09:42 PM Re: mouse over/out events with elements inside a div
Extreme Talker

Posts: 238
Location: United States
Trades: 0
My guess is that you need to cancel bubbling/propagation on your events. As it stands now, it is likely triggering on every single inner element you move in or out of inside the barCurrency div.
__________________
The interlocking pieces of web development: usability, performance, accessibility, and standards.
frost is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to mouse over/out events with elements inside a div
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10204 seconds with 12 queries