SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2000
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Everyone,

    I'm having trouble with a bit of JavaScript. Does anyone know if it is possible to have 2 functions execute on a mouseOver event?

    For example, on my mouseOver, I want to have an image flip and I want to call another function that does something else.

    I tried comma and semi separated, but that doesn't seem to do it.

    Maybe I could write one function that calls the other 2??

    HELP!! Any ideas would be appreciated!!

    Thanks,

    Mark

  2. #2
    SitePoint Wizard big_al's Avatar
    Join Date
    May 2000
    Location
    Victoria, Australia
    Posts
    1,661
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Heres somthing similar to what your after, it does a rollover and display a message in a table.

    <script LANGUAGE="JavaScript">

    <!--

    // load up all the rollovers
    blankmsg = new Image();
    blankmsg.src = "images/blank_msg2.gif";

    about0 = new Image();
    about0.src = "images/aboutbuttonred.gif";
    about1 = new Image();
    about1.src = "images/aboutbuttonyel.gif";
    aboutmsg = new Image();
    aboutmsg.src = "images/aboutro.gif";
    loadedImages = 1;

    function doRollover (theButton, state) {
    if (document.images && loadedImages && ( document[theButton] )) {
    document[theButton].src = eval (theButton + state + ".src");
    (state) ?
    document['msgArea'].src = eval (theButton + "msg.src"):
    document['msgArea'].src = blankmsg.src;
    }
    }



    //-->
    </script>

    <a href="about.htm" onMouseOver="doRollover('about',1)" onMouseOut="doRollover('about',0)"><img name="about" src="images/aboutbuttonred.gif" alt="About" width="223" height="34" border="0"></a>


    <!-- This is the part of the table with the message appears in, Note the img tag //-->

    <td valign="top" align="left" width="213"><img name="msgArea" src="images/blank_msg2.gif" height="169"></td>

    Hope this helps you a bit or atleast points you in the right direction.
    .NET Code Monkey

  3. #3
    SitePoint Enthusiast
    Join Date
    Feb 2000
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Big Al.

    I'll see if I can use that to get me started!

    Appreciate it.

    Mark

  4. #4
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Separating the two calls by a semicolon should work:

    onMouseOver="function1();function2();"

    If this doesn't work, post your code so we can see the cause.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  5. #5
    Non-Member JAMJAMMO's Avatar
    Join Date
    Dec 2000
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HI, i posted a similar question a few days ago and i got my answer. but i actually found a shorter way. here are teh two events i wanted to combine:

    Code:
    onMouseOver="imgover(pic1)"
    onMouseover="changetext(content[0])"
    instead of going through my documents and practically rewriting it all, heres how i fixed it:

    Code:
    onMouseOver="imgover(pic1), changetext(content[0])"
    at first i tried doing this:

    Code:
    onMouseOver="imgover(pic1)","changetext(content[0])"
    adn this also:
    Code:
    onMouseOver="imgover(pic1)";"changetext(content[0])"

    i hope this short method works for you like it did for me.

  6. #6
    JavaScript Guru (Big Ego) Arielladog's Avatar
    Join Date
    Jul 1999
    Location
    SC, USA
    Posts
    390
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey JamJammo et all,

    Actually, this shouldn't work:
    Code:
    onMouseOver="imgover(pic1), changetext(content[0])"
    But rather it should be:
    Code:
    onMouseOver="imgover(pic1); changetext(content[0])"
    I think Kevin (kyank) already explained this answer.

    aDog

  7. #7
    SitePoint Wizard silver trophy Karl's Avatar
    Join Date
    Jul 1999
    Location
    Derbyshire, UK
    Posts
    4,411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    onMouseOver="imgover(pic1); changetext(content[0])"
    Is the way it should work, if it does not then make sure each of the functions called returns a value at the end of it's execution else it may stop it from executing the second function.
    Karl Austin :: Profile :: KDA Web Services Ltd.
    Business Web Hosting :: Managed Dedicated Hosting
    Call 0800 542 9764 today and ask how we can help your business grow.

  8. #8
    Non-Member JAMJAMMO's Avatar
    Join Date
    Dec 2000
    Posts
    106
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oh yeah,

    oops. i meant ';' not ','

    thanks for the correction.
    but it actually IS working with the comma and it DOESNT work with the semicolon.

    aint it weird?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •