I have 2 .js files – x.js and y.js.
The 2 files are the same, except for x.js holds an onClick event function for one button which displays where div id=’xjs’.
the second file y.js holds an onClick event function for another button which displays where div id=’yjs’.
I have a table, in the left column is my div id=’xjs’, and in the right column is my div id=’yjs’.
When I click the first button, the correct text appears in the xjs div, but when I click the second button the text overwrites the xjs div and does not appear in the yjs div area.
Here is the code I’m using from the .js files.
[QUOTE]
var xmlHttp
// Check if browsers support AJAX
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
{
xmlHttp=new ActiveXObject(“Msxml2.XMLHTTP”);
}
catch (e)
{
xmlHttp=new ActiveXObject(“Microsoft.XMLHTTP”);
}
}
return xmlHttp;
}
// here the div id should = yjs
function stateChanged()
{
if (xmlHttp.readyState == 4 || xmlHttp.readyState == “complete”)
{
document.getElementById(“yjs”).innerHTML = xmlHttp.responseText
}
}
function warpUser(str)
{
xmlHttp = GetXmlHttpObject()
if(xmlHttp == null)
{
alert(“Browser does not support HTTP Request”)
return
}
// call the .php file to do the work
var url = “action.php”
url = url + “?id=” + str
url = url + “&sid=” + Math.random()
xmlHttp.onreadystatechange = stateChanged
xmlHttp.open(“GET”,url,true)
xmlHttp.send(null)
}
I believe the problem to be in the stateChanged() function. But I do not know how to output to multiple areas, only one. I would like to output to multiple areas, that is my goal. Please assist.
Brandon