PDA

View Full Version : document.getElementById(variable)



city_coder
06-17-2008, 12:31 PM
ok guys this should be so simple, in fact it is so simple that its working...in firefox but not in IE?!?!

Iv got to the point where its driving me nuts and what i have found is that for some reason when i put a variable in the document.getElementById() section, IE doesnt like it.

http://www.mewan.net/mark/hwutl/index.php?id=8

if you right click and view source then you will see how i put var string in section and how i build it.



var string = 'ajaxDiv' + div_id;
document.getElementById(string).style.display = "block";
xmlHttp.onreadystatechange=function() {
if(xmlHttp.readyState==4) {
var ajaxDisplay = document.getElementById(string);
ajaxDisplay.innerHTML = xmlHttp.responseText;
} else {
var ajaxDisplay = document.getElementById(string);
ajaxDisplay.innerHTML = "<p>Loading....</p>";
}


is there anything anyone can suggest? please im going nuts!

boogyman
06-17-2008, 01:11 PM
what is div_id? and where is that variable coming from

city_coder
06-17-2008, 01:28 PM
div_id is the 2nd variable sent through. its just a incrementor in php from a while loop.

if you see further down the page, the main part. it has


<a href="#" onclick="ajaxFunction(this.id, 1)" id="4">Changes on the Farm</a>

that is one of the examples, its the main part