Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Dec 2003
    Location
    America
    Posts
    544
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Another function again not working.

    I need help detecting the error in this:

    Code:
    function imageFlips(paramOne, paramTwo)
    {
    if(document.images)
      {
        document.image.paramOne.src=paramTwo;
      }
    else
      {
        alert("There's no image by the name of "+paramOne);
      }
    }
    I call the above with the following code:

    Code:
    <br>
    <a href="javascript:onMouseOver="imageFlips('flower','triangle.bmp');">
    <img id="flower" src="flower.bmp">
    </a>
    <br>
    I do not know why the onMouseOver event-handler does not call the function.
    LovesWar

  • #2
    New Coder
    Join Date
    May 2004
    Location
    Some place called the Earth I think...
    Posts
    99
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try <a href="javascript:void(0);" onmouseover="your function here" >
    Dont do drugs, get high on life

    13 years and getting nowhere fast.....


    M_Mk

  • #3
    Regular Coder
    Join Date
    Dec 2003
    Location
    America
    Posts
    544
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Sorry, but no go.

    Still not working. Funny thing is, that the alert part works. And it tells me theres no image by that name, when in fact there is one. LOL.
    LovesWar

  • #4
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    document.images[paramOne].src=paramTwo;

  • #5
    Regular Coder
    Join Date
    Dec 2003
    Location
    America
    Posts
    544
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thank you, a billion times.

    It worked. And i was gonna try the paramOne within the images array, but i somehow second guessed myself. anyways, i had to throw in the s part in the document.image array, to make it document.images[].

    In the end, it worked. And i even tried a reversal of the code a little, and that too worked. Here's my code:

    Code:
    <br>
    <a href="javascript:void(0);" 
    
    onmouseover="imageFlips('flower','triangle.bmp');"
    onmouseout="imageFlips('flower','flower.bmp');">
    <img id="flower" src="flower.bmp">
    </a>
    <br>
    I threw in the onmouseout event-handler to see if i could reverse the flip, and it worked.
    LovesWar


  •  

    Posting Permissions

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