kfcSmitty got it spot on! That's exactly what I was trying to achieve.
Basically the reason I'm doing this is I've got a JS function that I use for AJAX. It's all fine when I'm updating the webpage, but when I want to update a JS variable, it's a different story.
Here's what I mean:
PHP Code:
var httpReqs = new Array;
function getFromServer(queryAndURL, idToUpdate)
{
var newUpper = 0;
httpReqs[httpReqs.length+1]=false;
newUpper=httpReqs.length;
if(navigator.appName == "Microsoft Internet Explorer")
{
httpReqs[newUpper] = new ActiveXObject("Microsoft.XMLHTTP");
}
else
{
httpReqs[newUpper] = new XMLHttpRequest();
}
httpReqs[newUpper].open("GET", queryAndURL, true);
httpReqs[newUpper].onreadystatechange=function()
{
if(httpReqs[newUpper].readyState == 4)
{
document.getElementById(idToUpdate).innerHTML = httpReqs[newUpper].responseText;
}
}
httpReqs[newUpper].send(null);
return 0;
}
I will be modifying this function so that when called, it updates what ever variable that's passed as a parameter.