Bind form items to userData attributes

I do not use much JavaScript so i apologize if there is a blatantly obvious error. I am trying to make an object which allows me to bind the item ID of a form element to the userdata of my tree nodes. The desired effect should be as i click a tree node the user data is pushed to its corresponding form elements and as the onchange event fires on form elements the new value is stored in the user data for the selected tree node.

<script type="text/javascript">
function forEachIn(object, action) {
  for (var property in object) {
    if (Object.prototype.hasOwnProperty.call(object, property))
      action(property, object[property]);
  }
}

function addEvent(element, event, callback){
  var isIE = (document.all) ? true : false;

  if(isIE){ 
    element.attachEvent('on' + event,callback);
  }else{
    element.addEventListener(event,callback,false);
  }
}

function dataBinder(bindingObj){
	this.bindingObj = bindingObj
	this.boundItems = {};
}
dataBinder.prototype.add = function(formItem, userDataName){
	this.boundItems[formItem] = userDataName;
}
dataBinder.prototype.bind = function(){
	var self = this;
	this.bindingObj.attachEvent('onClick',self.refresh);
	
	var ele;
	forEachIn(this.boundItems,function(formItem, userDataName){
		ele = document.getElementById(formItem);
		addEvent(ele,'change',function(){
			self.bindingObj.setUserData(self.bindingObj.getSelectedItemId(),
			                                            userDataName,
														ele.value);
		});
	});
}
dataBinder.prototype.refresh = function(){
	var self = this;
	forEachIn(this.boundItems,function(formItem,userDateName){
		document.getElementById(formItem).value = self.bindingObj.getUserData(self.bindingObj.getSelectedItemId(),userDataName);
	});
}

</script>

if i had the following input within my form and i instanciated my dhtmlxtree as “tree” I would use the following code to bind my input to the user data.

<input type="text" value="" id="P150_SERIAL">

var db = new dataBinder(tree);

db.add('P150_SERIAL','serial');
db.bind();

any help would be greatly appreciated