-
SitePoint Enthusiast
variables in objects??
hi,
This has been killing me for ages and I've had nobody to ask, is it possible to recall variables in objects. For example an img swap :
<a href="#" onMouseOver="imgSwap('link1');"><img src=".." name="link1"></a>
<a href="#" onMouseOver="imgSwap('link2');"><img src=".." name="link2"></a>
.
.
.
.
function imgSwap(imgNo){
window.[imgNo].src = 'whatever';
}
now I know that the eg wouldn't work but is there any way of doing something like that?
-
Hey,
I'm not quite sure what you mean, but if you accessed the object correctly, it should work:
document.[imgNo].src = 'whatever';
or:
document.images.[imgNo].src = 'whatever';
aDog
-
SitePoint Enthusiast
it doesn't work for me, it comes up with an 'object expected' error.
Last edited by DarknessAwaits; Dec 5, 2001 at 16:08.
-
Hey,
It should be:
document[imgNo].src = 'whatever';
or:
document.images[imgNo].src = 'whatever';
There was an extra "dot" in there.
My bad,
aDog
-
SitePoint Enthusiast
wehey! that works 
u've made me a happy man... oh god how sad that sounds...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
Bookmarks