user interface - JavaScript: Getting the right UI element in a list of them -
i building ui in javascript involves adding column of checkboxes:
for (var key in processandportlist.list) { if (processandportlist.list.hasownproperty(key)) { var datarow = mytable.insertrow(-1); var datacell = datarow.insertcell(-1); datacell.textcontent = key; datacell = datarow.insertcell(-1); datacell.textcontent = processandportlist.list[key].port; var terminationcheckbox = document.createelement('input'); terminationcheckbox.type = "checkbox"; terminationcheckbox.id = key; terminationcheckbox.checked = processandportlist.list[key].markedfortermination; terminationcheckbox.onchange = function() { var ischecked = terminationcheckbox.checked; markfortermination(key, ischecked); }; var terminatecell = datarow.insertcell(-1); terminatecell.appendchild(terminationcheckbox); } }
the problem comes in associating correct id callback when checkbox each entry checked. can't seem that checkbox's id function. ever last checkbox's id. how can correct id?
changing should work:
terminationcheckbox.onchange = function() { markfortermination(this.id, this.checked); };
Comments
Post a Comment