Obtaining the relative path with image.src
In this code target.src evaluates to "http://localhost/images.collapse-gray.GIF" which is no code for me to hardcode, because when I move it to the production server "localhost" won't work:
//Will toggle the image between collapsed and expanded
function ToggleCollExpImage( targetId ){
if (document.getElementById){
target = document.getElementById( targetId );
if (target.src == "images/collapse-gray.GIF"){
target.src = "images/expand-blue.GIF";
} else {
target.src = "images/collapse-gray.GIF";
}
}
}
<img src="./images/collapse-gray.GIF" id="imgDemographicsCollapseExpand" height="14" width="14" onclick="ToggleDisplay('tblDemographics');ToggleCollExpImage('imgDemographicsCollapseExpand');" />

