I'm trying to use a function to toggle two divs and an image source using the image as a link. The link and image are output using asp like this:
Code:
<a href=""javascript:showTracks('" & CStr(intTrackList) & "');""><img src='images/expand.gif' id='expand" & CStr(intTrackList) & "' width='48' border='0'/></a>
div 1 -
Code:
<div class='trackcount' align='center' id='trackcount" & CStr(intTrackList) & "'>blah blah</div>
Code:
<div class='tracklist' id='tracklist" & CStr(intTrackList) & "' align='center'>blah blah</div>
Code:
function showTracks(id){
if(document.getElementById){
if(document.getElementById("expand"+id).src="images/expand.gif"){
document.getElementById("trackcount"+id).style.display=document.getElementById("trackcount"+id).style.display?"block":"none";
document.getElementById("tracklist"+id).style.display=document.getElementById("tracklist"+id).style.display?"none":"block";
document.getElementById("expand"+id).src="images/hide.gif";
}
else if(document.getElementById("expand"+id).src="images/hide.gif"){
document.getElementById("trackcount"+id).style.display=document.getElementById("trackcount"+id).style.display?"none":"block";
document.getElementById("tracklist"+id).style.display=document.getElementById("tracklist"+id).style.display?"block":"none";
document.getElementById("expand"+id).src="images/expand.gif";
}
}
}
When I click the link again the two divs are switched but the image is not changing. Worse yet the link now produces no actions on subsequnt clicks.
Any help is greatly appreciated. Thanks in advance.