javascript - buttons added to table won't fire handler -


in table, i'm trying include edit button @ end of each row. idea user click 1 of these alter row's content. can build , populate table fine, cannot buttons fire off handler.

here's code snippet:

window.onload = function (){   // bunch of stuff happens correctly...    while (!rs.eof)   {     var orow = oticketstable.insertrow();      (j=0; j < field.length; j++)     {       var ocell = orow.insertcell();        ocell.style.fontsize = "10";       ocell.style.fontweight = "normal";       ocell.style.border = "thin black solid";       ocell.innertext = rs(field[j]);     }      var ocell = orow.insertcell();     ocell.style.border = "thin black solid";      var obtn = document.createelement("button");     ocell.appendchild(obtn);      obtn.innerhtml = rs('idnum');     obtn.onclick = function () { alert("obtn.onclick"); }      rs.movenext();   }    rs.close ();   delete rs;    var btn = document.createelement("button");   btn.style.height = "50px";   btn.style.width = "150px";   document.body.appendchild(btn);    btn.innerhtml="button1";   btn.onclick = function() { alert("button1 calling");  } 

the code @ end creates test button fires off fine. none of buttons in table work.

the onclick function in table camel case: try changing lower case? change obtn.onclick obtn.onclick.

obtn.onclick = function () { alert("obtn.onclick"); } 

Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -