Click to See Complete Forum and Search --> : image swap...


xataku_nakusute
08-04-2003, 12:32 AM
i need a script that swaps multiple images, in which when i call the function, i type swap('../myimg.gif') to specify which image i want it to change into. also, i need it to change back to the original when a different image is clicked...

i hope you can do this...

gil davis
08-04-2003, 06:24 AM
If you only have one active "swap", jut keep track of that one and then "unswap" it when the next one is "swapped". Something like this:

var activeImg = null; // first time it will be empty
...
function unSwap() {
document.images[activeImg.name].src = activeImg.src;
}

function swap(nm, src) {
if (activeImg) unSwap();
activeImg = new Image();
activeImg.name = nm; // remember the old state
activeImg.src = document.images[src];
document.images[nm].src = src; // do the swap
}

xataku_nakusute
08-04-2003, 06:02 PM
i need multiple images to swap...(at different times)...