HTA: How so I tell which button was clicked if dynically generated?

Basically, when I dynamically create the submit buttons, the “onclick” parameter won’t allow me to pass a function with a parameter so all of my created submit buttons all have the same function. So my question is, within that function, how do I determine which of my 15 submit buttons were clicked so I can take the appropriate action on the one being run? Thanks in advance. Here is the javascript portion of what I’ve got so far:

 <script type="text/javascript">
  
  var mySites = new Array();
  mySites[0] = ['site1', '\\\\\\\\uncpath'];
  mySites[1] = ['site1', '\\\\\\\\uncpath'];
  mySites[2] = ['site1', '\\\\\\\\uncpath'];
  mySites[3] = ['site1', '\\\\\\\\uncpath'];
  mySites[4] = ['site1', '\\\\\\\\uncpath'];
  mySites[5] = ['site1', '\\\\\\\\uncpath'];
  mySites[6] = ['site1', '\\\\\\\\uncpath'];
  mySites[7] = ['site1', '\\\\\\\\uncpath'];
  mySites[8] = ['site1', '\\\\\\\\uncpath'];
  mySites[9] = ['site1', '\\\\\\\\uncpath'];
  mySites[10] = ['site1', '\\\\\\\\uncpath'];
  mySites[11] = ['site1', '\\\\\\\\uncpath'];
  mySites[12] = ['site1', '\\\\\\\\uncpath'];
  mySites[13] = ['site1', '\\\\\\\\uncpath'];
  mySites[14] = ['site1', '\\\\\\\\uncpath'];
  mySites[15] = [site1', '\\\\\\\\uncpath'];
  
  function loadButtons() {
   var myDiv = document.getElementById("divMain");
   var myTable = document.createElement("table");
   myTable.setAttribute('id', "sites");
   var myTbody = document.createElement("tbody");
    
   for (var i=0; i < mySites.length; i++) {
    var myTr = document.createElement("tr");
    var myTd1 = document.createElement("td");
    var myTd2 = document.createElement("td");
    var myTd3 = document.createElement("td");
    
    myTd1.appendChild(document.createTextNode(mySites[0]));
    myTr.appendChild(myTd1);
    
    myTd2.appendChild(document.createTextNode(mySites[1]));
    myTr.appendChild(myTd2);
    
    var myButton = document.createElement('input');
    myButton.type = 'button';
    myButton.name = mySites[1];
    myButton.value = "Update";
    myButton.onclick = updateDefFiles;  <------------
    myTd3.appendChild(myButton);
    myTr.appendChild(myTd3);
    
    myTbody.appendChild(myTr);
    myTable.appendChild(myTbody);
    myDiv.appendChild(myTable);
   }
  }
  
  function updateDefFiles() {
   alert("hiyo");
  }
  
 </script>

If I could somehow, I’d love to change this: myButton.onclick = updateDefFiles; to this: myButton.onclick = updateDefFiles(mySites[0]);

But I don’t believe this can be done (at least from what I’ve read on my Google searches). So I think I’m stuck with just using my updateDefFiles() generic function. But once that function is called, how can I determine which of my submit buttons was clicked? TIA!

is this what you’re trying to achieve?


var mySites = new Array();
  		mySites[0] = ['site0', '\\\\\\\\uncpath'];
  		mySites[1] = ['site1', '\\\\\\\\uncpath'];
  		mySites[2] = ['site2', '\\\\\\\\uncpath'];
  		mySites[3] = ['site3', '\\\\\\\\uncpath'];
  		mySites[4] = ['site4', '\\\\\\\\uncpath'];
  		mySites[5] = ['site5', '\\\\\\\\uncpath'];
  		mySites[6] = ['site6', '\\\\\\\\uncpath'];
  		mySites[7] = ['site7', '\\\\\\\\uncpath'];
  		mySites[8] = ['site8', '\\\\\\\\uncpath'];
  		mySites[9] = ['site9', '\\\\\\\\uncpath'];
  		mySites[10] = ['site10', '\\\\\\\\uncpath'];
  		mySites[11] = ['site11', '\\\\\\\\uncpath'];
  		mySites[12] = ['site12', '\\\\\\\\uncpath'];
  		mySites[13] = ['site13', '\\\\\\\\uncpath'];
  		mySites[14] = ['site14', '\\\\\\\\uncpath'];
  		mySites[15] = ['site15', '\\\\\\\\uncpath'];

  		function loadButtons() {
	   		var myDiv = document.getElementById("divMain");
		   	var myTable = document.createElement("table");
		   	myTable.setAttribute('id', "sites");
		   	var myTbody = document.createElement("tbody");

   			for (var i=0; i < mySites.length; i++) {
				var myTr = document.createElement("tr");
				var myTd1 = document.createElement("td");
				var myTd2 = document.createElement("td");
				var myTd3 = document.createElement("td");
	
				myTd1.appendChild(document.createTextNode(mySites[i]));
				myTr.appendChild(myTd1);
	
				myTd2.appendChild(document.createTextNode(mySites[i]));
				myTr.appendChild(myTd2);
	
				var myButton = document.createElement('input');
				myButton.type = 'button';
				myButton.name = mySites[i];
				myButton.value = "Update";
				myButton.onclick = updateDefFiles;
				myTd3.appendChild(myButton);
				myTr.appendChild(myTd3);
	
				myTbody.appendChild(myTr);
				myTable.appendChild(myTbody);
				myDiv.appendChild(myTable);
   			}
  		}

  		function updateDefFiles(o) {
  			alert(this.name);
  		}