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


wynton_ca
05-27-2003, 01:07 PM
I was hoping someone could help me with this problem Im facing. I have this code which swaps the link display name, but I need it to swap an image.

the .js:

function toggle_innertext_display(thisElement,displayedText1,displayedText2) {
if (thisElement.innerHTML == displayedText1) {
thisElement.innerHTML = displayedText2;
}
else if (thisElement.innerHTML == displayedText2) {
thisElement.innerHTML = displayedText1;
}
else {
thisElement.innerHTML = displayedText1;
}

}


The anchor link which calls the function:

<a href="#" onclick="toggle_innertext_display(this,'Show Details','Hide Details');"><img src="/root/images/tabs/tab_show_details.gif" width="113" height="27" alt="Show Details" border="0"></a>

Thanks!
wynton

khalidali63
05-27-2003, 01:12 PM
instead of this part of the code

if (thisElement.innerHTML == displayedText1) {
thisElement.innerHTML = displayedText2;

replace it with
if (thisElement.childNodes[0].src="someImage"){
thisElement.childNodes[0].src="another image"
}else{
thisElement.childNodes[0].src="some other image"
}

wynton_ca
05-27-2003, 01:25 PM
do i need to name the image? and how would i pass the correct parameters into the function so that it recognizes the image swap?