Note that there are some explanatory texts on larger screens.

plurals
  1. POAdding a row to a table
    primarykey
    data
    text
    <p>I have written a code to add a new row dynamically on a click of a button. There are 5 columns.</p> <p>The third column contain Two <strong>radio buttons</strong>, and on click of each radio button, new options appear. This Works Fine for the first row, but as soon as I click on the button to generate a new row problems start.</p> <p>When I click on the radio button of the second row, options appear on the first row. Instead I want them to appear in that specific column.</p> <p><strong>Here is my code for adding a row</strong></p> <pre><code>function addRow(tableID) { var table = document.getElementById(tableID); var rowCount = table.rows.length; var row = table.insertRow(rowCount); var colCount = table.rows[0].cells.length; for(var i=0; i&lt;colCount; i++) { var newcell = row.insertCell(i); newcell.innerHTML = table.rows[1].cells[i].innerHTML; } } </code></pre> <p><strong>And this is my table</strong></p> <pre><code>&lt;TABLE id="dataTable" border="1"&gt; &lt;td&gt;&lt;input type="text" id=1 /&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" id=2 /&gt;&lt;/td&gt; &lt;td&gt; &lt;input type="radio" name="radio1" value="1" onClick="toggleDisplay('mydiv','mydiv1');"&gt;Own &lt;input type="radio" name="radio2" value="1" onClick="toggleDisplay1('mydiv','mydiv1');"&gt;Contractor &lt;div id="mydiv" style="display:none;"&gt; &lt;input type="radio" name="Wage" value="Wage"&gt;Wage Board &lt;input type="radio" name="Staff" value="Staff"&gt;Staff &lt;/div&gt; &lt;div id="mydiv1" style="display:none;"&gt; Name Of Contractor:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;input type="text" name = "text" &gt; &lt;input type="radio" name="No" &gt;No of Workmen &lt;/div&gt; &lt;/td&gt; &lt;td&gt;&lt;input type="text" id=5 /&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="text" id=4 /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/TABLE&gt; &lt;INPUT type="button" value="Add Row" onclick="addRow('dataTable')" /&gt; </code></pre> <p>Please help me out on this one as soon as possible. I think the problem is with unique ids.</p>
    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.
 

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