SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Several functions in onmouseover?

    Hey

    How can i use one than more function in an onmouseover call? I tried this:

    Code:
    <script language="javascript">
    // Show the text from a given dates appointment
    function showLink(id){
    	var url = "sites/calendar_information.php?id="+id;
    	xmlHttp.open("GET", url, true);
    	xmlHttp.onreadystatechange=stateChangedShowLink;
    	xmlHttp.send(null);
    }
    
    function stateChangedShowLink(){
    	if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    	{
    		document.getElementById("information_content").innerHTML=xmlHttp.responseText;
    	}
    }
    
    // Show the specific date for a appointment
    function showLinkDate(date){
    	var url = "sites/calendar_show_date.php?date="+date;
    	xmlHttp.open("GET", url, true);
    	xmlHttp.onreadystatechange=stateChangedShowLinkDate;
    	xmlHttp.send(null);
    }
    
    function stateChangedShowLinkDate(){
    	if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    	{
    		document.getElementById("information_title").innerHTML=xmlHttp.responseText;
    	}	
    }
    </script>
    <?php
    $cell = "<div class='everyDay' onmouseover=\"this.className='everyDayHover'; showLink('$cellValue'); showLinkDate($date);\" onmouseout=\"this.className='everyDay';\"'>$cellValue</div>";
    ?>
    And it doesnt work. If i remove one of the functions in the onmouseover call the ohter function works fine. So the function calls works, just not when i call them both. How do i do this?

    **I didnt post the whole script thats why the php part looks a little "undone"

  2. #2
    Avid Logophile silver trophy
    ParkinT's Avatar
    Join Date
    May 2006
    Location
    Central Florida
    Posts
    2,329
    Mentioned
    191 Post(s)
    Tagged
    4 Thread(s)
    First, realize that EVERY function returns a boolean value. You can set an explicit return to control whether (or not) the next statement (ie function call) is executed.

    More to your point, simply create a SINGLE function to call in your "onmouseover" that calls each of the other functions in sequence.
    Don't be yourself. Be someone a little nicer. -Mignon McLaughlin, journalist and author (1913-1983)


    Git is for EVERYONE
    Literally, the best app for readers.
    Make Your P@ssw0rd Secure
    Leveraging SubDomains

  3. #3
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i did try that too, i tried the following:

    function test(date){
    showLink(date);
    showLinkDate(date);
    }

    but same result, none of the functions works and even if i remove one of them the ohter doesnt work.

  4. #4
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    okay... it works in IE but not in FireFox. I installed FireBug in FF and it gives me JavaScript errors, so i guess that without isnt right?

  5. #5
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    FireBug give me the following error msg:

    uncaught exception: [Exception... "Component returned failure code: 0xc1f30001 (NS_ERROR_NOT_INITIALIZED) [nsIXMLHttpRequest.send]" nsresult: "0xc1f30001 (NS_ERROR_NOT_INITIALIZED)" location: "JS frame :: javascript: eval(__firebugTemp__); :: anonymous :: line 1" data: no]

  6. #6
    SitePoint Addict
    Join Date
    Dec 2007
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It would be a lot easier to debug if you have a test case setup somewhere.

    The code looks correct.

    This would be a "cleaner" way to do it though.

    document.getElementSomehow().onmouseover = function(){
    func1();
    func2();
    func3();
    }

    Quote Originally Posted by ParkinT View Post
    First, realize that EVERY function returns a boolean value.


    Every function's return value is converted to a boolean when you test it (if/else, etc.) but a function can return anything.


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
  •