Click to See Complete Forum and Search --> : Swap multiple images.


sunitad
01-29-2003, 09:45 AM
I am using DOM model.
I need to swap all images on a page which has a div expanggif.

I have many more images but i want to change only those one with a new image say openthis.gif.

Please help me this is urgent!

Thanks in advance.

I used this code when I used name of image but has errors...

if(document.images){
var len=document.getElementsByTagName('img').length;
//if you know the number of images then you can directly put the number in place of len
for(x=1;x<len;x++){
var str="fold"+x;
var objStr,obj;;
objStr = 'document.' + str;
obj = eval(objStr);
document.images[obj].src="openfolder.jpg";
}

If someone has a working code please give me that.

sunitad
01-29-2003, 10:14 AM
Just found the answer.

Its working on IE have to check on NS.

When all images are named as foldx.

function changeAllImages(){
if(document.images){
var len=document.getElementsByTagName('img').length;
//if you know the number of images then you can directly put the number in place of len
for(x=1;x<len;x++){
var str="fold"+x;
Obj1 = eval("document.images['" + str+ "']");
if(!Obj1){
break; }
Obj1.src="openfolder.gif";
//imgchange(str)
}
}
}