header image
 

dynamically generated onclick events for dynamically generated elements

scenario

while looping thru elements (checkboxes) in a grid, i need to add onclick handlers (clientside) to each box, that does something to another control in the same row

chkGross.onclick = function(){UpdateDefaults(sGrossNettTableId, sGRossNettDefaultTableId)};   // doesnt work

 chkGross.onclick = new Function(“UpdateDefaults(‘” + sGrossNettTableId + “‘,'” + sGRossNettDefaultTableId + “‘)”) // WORKS!!!

Use the new Function() method if you need dynamically generated onclick events for dynamically generated elements

Javascript: Dynamically Change onclick Event « Chovy’s Blog

dynamically generated onclick events for dynamically generated elements

~ by shoel on February 26, 2010 .



Leave a Reply