Hi guys,
I’m trying to write a script to dynamically grab data from a data base. When the page is rendered, php and mysql do their thing and create a table of all the information. When I click on one of the names of each item, the text box beside it will grab data from the database and stick it in the textarea.
My problem is that when I call the getHistory() function, I want to pass two parameters to it: the ID (input) of the title being clicked and then the Output ID of the textarea for that individual “row” of data.
But my problem becomes that I can only pass the input parameters…but can’t actually put the output where I want them to go because the onreadystatechange handler is OUTSIDE of the getHistory function…
So basically, how can I add the handleHttpResponse function to be included in the getHistory function so that I can easily pass multiple parameters into it. Thanks! Here’s the code:
PS – Once again sadly only testable in IE.
[CODE]var url = “phpfile.php?getHist=”;
var http = new ActiveXObject(“Microsoft.XMLHTTP”);
function getHistory(input) {
http.open(“GET”, url+input, true);
http.onreadystatechange = handleHttpResponse;
http.send(null);
}
function handleHttpResponse() {
if (http.readyState == 4) {
results = http.responseText;
document.getElementById(‘OUTPUT-ID-HERE’).value = results;
}
}
Want it to “look” like this:
[CODE]var url = “phpfile.php?getHist=”;
var http = new ActiveXObject(“Microsoft.XMLHTTP”);
function getHistory(INPUT,OUTPUT) {
http.open(“GET”, url+INPUT, true);
http.onreadystatechange do this:
if (http.readyState == 4) {
results = http.responseText;
document.getElementById(‘OUTPUT’).value = results;
}
http.send(null);
}
}