Hello everyone,

Long time lurker, first time poster.

I'm trying to implement an AJAX inline editor and am having some trouble. I want to use this editing field several times on
the same page, and was hoping to make the JavaScript reusable, passing
it the name of the fields that need to change, but I'm having some
trouble. In particular, I'm having trouble here:

function sndReq(action) {
http.open('get', action);
http.onreadystatechange = handleResponse;

function handleResponse() {
if(http.readyState == 4){
var replaceText = document.getElementById(name_textbox).value;
document.getElementById('name_displaybox_contents').innerHTML = replaceText;
document.getElementById('name_displaybox').style.display = '';
document.getElementById('name_editingbox').style.display = 'none';

My thought was that at the <http.onreadystatechange = handleResponse;>
line I could pass the value of the field element I'm using on to the
handleResponse function and then use it to swap out the
getElementByIds so that I wouldn't need to replicate all this code for
the different chunks I'm swapping out. However, the http.readyState
is making things difficult for me; for some reason, if I pass a
variable on to handleResponse, the "if (http.readyState == 4)" doesn't get

Does this make any sense? I don't know, because it doesn't make sense to me either. If you could help me out I'd be greatly in your debt!