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 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2003
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    using the same name attribute

    I'm using the following functions to create a link pointer such that there is a list of links, and onMouseOver, a green arrow appears beside that link. The default image is a transparent image as place holder.

    function ovr() { document.images['arr'].src = "images/_arr_arrow.gif"; }
    function out() { document.images['arr'].src = "images/_arr_hold.gif"; }

    <a href="" onMouseOver="ovr()" onMouseOut="out()"><img src="images/_arr_hold.gif" name="arr">link text 1</a>
    <a href="" onMouseOver="ovr()" onMouseOut="out()"><img src="images/_arr_hold.gif" name="arr">link text 2</a>
    ...so on

    Problem is that when I have more than one link, it only works on the last link. There are no effects or error messages for the links above the last one.

    I've seen examples where the name attribute of the place holder for each link is given a different name and then passing that name thru the function. Is there a way around it? Because it would generate a lot more code and I have much more code than shown above. Thanks.

  • #2
    Regular Coder
    Join Date
    Nov 2002
    Posts
    596
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Code:
    function ovr(n) {
    document.arr[n].src = "images/_arr_arrow.gif";
    }
    
    function out(n) {
    document.arr[n].src = "images/_arr_hold.gif";
    }
    
    <a href="" onMouseOver="ovr(0)" onMouseOut="out(0)"><img src="images/_arr_hold.gif" name="arr">link text 1</a>
    <a href="" onMouseOver="ovr(1)" onMouseOut="out(1)"><img src="images/_arr_hold.gif" name="arr">link text 2</a>

  • #3
    New Coder
    Join Date
    Mar 2003
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts
    works! thanks!


  •  

    Posting Permissions

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