Jump to content

Multiple getElementById in same page


solarisuser

Recommended Posts

Hello All,

 

I am having a problem that when I click on one of the two collapsible dropdown links on the same page..

<a href="#test" onClick="shoh('test');" ><img src="arrow.gif" name="imgtest" border="0">Test Fields</a>

the picture for both do not change.  Only the first link changes.  I am pretty sure I need to look at using getElementByName or maybe something else, but all the various modifications I've tried have not worked.  Can someone point me in the right direction?

 

Here is the rest of the code incase someone would like to try it out...

 

<div style="display: none;" id="test" ><table><tr><td><input type=text name=name></td></tr></table></div>

 

Here is the JS code that I include at the top of the page..

imgout=new Image(9,9);
imgin=new Image(9,9);

/////////////////BEGIN USER EDITABLE///////////////////////////////
imgout.src="arrow.gif";
imgin.src="arrow2.gif";
///////////////END USER EDITABLE///////////////////////////////////

//this switches expand collapse icons
function filter(imagename,objectsrc){
if (document.images){
	document.images[imagename].src=eval(objectsrc+".src");
}
}

//show OR hide funtion depends on if element is shown or hidden
function shoh(id) { 

if (document.getElementById) { // DOM3 = IE5, NS6
	if (document.getElementById(id).style.display == "none"){
		document.getElementById(id).style.display = 'block';
		filter(("img"+id),'imgin');			
	} else {
		filter(("img"+id),'imgout');
		document.getElementById(id).style.display = 'none';			
	}	
} else { 
	if (document.layers) {	
		if (document.id.display == "none"){
			document.id.display = 'block';
			filter(("img"+id),'imgin');
		} else {
			filter(("img"+id),'imgout');	
			document.id.display = 'none';
		}
	} else {
		if (document.all.id.style.visibility == "none"){
			document.all.id.style.display = 'block';
		} else {
			filter(("img"+id),'imgout');
			document.all.id.style.display = 'none';
		}
	}
}
}

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/51395-multiple-getelementbyid-in-same-page/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.