...

View Full Version : using the same name attribute



loonatik
06-04-2003, 10:14 PM
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.

cheesebagpipe
06-04-2003, 10:30 PM
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>

loonatik
06-04-2003, 10:38 PM
works! thanks!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum