I have a image that I want to click and when clicked that image will be
swapped and then show a hidden div. When another image like it is
clicked it will swap image and hide that text and so on. My problem is
that when I send the Image ID's to the function I cannot find a way to
insert the dynamic names. I thought I could get the ID and concate the
string to use in the function but if I do IM = "I"+id; and stick it in
IM.SRC = ... it will not work but if I debug the value of IM it is
correct. If I manually put in IM33.SRC = ... it works but will not
work with the contacted value. What am I doing wrong? Thanks
var previd;
function swapImage(id) {
var nid = "id_"+id;
var el = document.getElementById(nid);
alert("before"+id);
var im = 'I'+id;
alert("after"+im);
if(previd!=null)
{
alert("in here"+im)
previd.style.display="none";
im.src = "images/plussign.gif"
return(false);
}
alert("Original"+im+"EL="+el);
displayType = (el.style.display == "none")?"block":"none";
el.style.display = displayType;
previd=el;
im.src = "images/minussign.gif"
return(false);
}