...

View Full Version : if(doc.images[0]==doc.images[i]) ???



BDT
04-08-2003, 05:41 AM
I am trying to use document.images[] to compare images to see if they are the same as follows:


for (i=1;i<=3;i++) {
if(document.images[0].src==document.images[i])


This isn't working and when I test it with:

alert("Image[0]= " + document.images[0].src + " and image " + i + " = " + document.images[i])

the test returns the proper image file name for what ever is on the left side of the conditional expression (==), but won't return the file of the image to the right. It just says that it is an [object].

I suppose that I could use some string functions like:


IMG= document.images[0].src;
IMGi= document.images[i].src;
(IMG.substring(0) if(IMG!=IMGi)

But I'm thinkin' there's a better way. Any suggestions??

thanks, BDT

x_goose_x
04-08-2003, 05:44 AM
if(document.images[0].src==document.images[i])


You only put src on one side. Maybe thats your prob.

BDT
04-08-2003, 01:45 PM
Doh!!! How can I look at something for so long and still not see it? I knew it would be simple, but didnt' think it would be THAT simple.

thanks

x_goose_x
04-08-2003, 07:23 PM
Expect it to happen again. The more you look at a script the more it merges together. I've done things like that all the time.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum