Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to put an onclick event for a HTML table row created dynamically through java script.?
    primarykey
    data
    text
    <p>I am new to javascript.</p> <p>Can anyone help me to implement an <code>onclick</code> event on click of a HTML table row created through javascript?</p> <p>Kindly note that I am inserting the data in table cells using <code>innerHTML</code>. Below is the code snippet of what i have tried.?</p> <p><strong>Java Script function:</strong></p> <pre><code>function addRow(msg) { var table = document.getElementById("NotesFinancialSummary"); var finSumArr1 = msg.split("^"); var length = finSumArr1.length-1; alert("length"+ length); for(var i=1; i&lt;finSumArr1.length; i++) { var row = table.insertRow(-1); var rowValues1 = finSumArr1[i].split("|"); for(var k=0;k&lt;=10;k++) { var cell1 = row.insertCell(k); var element1 = rowValues1[k]; cell1.innerHTML = element1; } } for(var i=1; i&lt;rowCount; i++) { for(var k=0;k&lt;=10;k++) { document.getElementById("NotesFinancialSummary").rows[i].cells[k].addEventListener("click", function(){enableProfileDiv()}, false); } } } </code></pre> <p><strong>HTML table code in jsp :</strong></p> <pre><code> &lt;TABLE id="NotesFinancialSummary" width="800px" border="1" align="left" &gt; &lt;tr &gt; &lt;th&gt;Symbol&lt;/th&gt; &lt;th&gt;Claimant&lt;/th&gt; &lt;th&gt;MJC&lt;/th&gt; &lt;th&gt;S&lt;/th&gt; &lt;th&gt;Type&lt;/th&gt; &lt;th&gt;Indemnity Resv&lt;/th&gt; &lt;th&gt;Indemnity Paid&lt;/th&gt; &lt;th&gt;Medical Resv&lt;/th&gt; &lt;th&gt;Medical Paid&lt;/th&gt; &lt;th&gt;Legal Resv&lt;/th&gt; &lt;th&gt;Legal Paid&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt; &lt;/td&gt; &lt;TD&gt; &lt;/TD&gt; &lt;TD&gt; &lt;/TD&gt; &lt;TD&gt; &lt;/TD&gt; &lt;TD&gt; &lt;/TD&gt; &lt;TD&gt; &lt;/TD&gt; &lt;TD&gt; &lt;/TD&gt; &lt;TD&gt; &lt;/TD&gt; &lt;TD&gt; &lt;/TD&gt; &lt;TD&gt; &lt;/TD&gt; &lt;TD&gt; &lt;/TD&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload