Note that there are some explanatory texts on larger screens.

plurals
  1. PODynamically add rows into a table using data from another table-jQuery
    text
    copied!<p>I have two table on my page like the picture shown here.<img src="https://i.stack.imgur.com/YojoR.png" alt="enter image description here"></p> <p>What I want to do is:</p> <ol> <li>select rows in the Source Table</li> <li>read the data in ID field, Name field from the Source Table, and also the value of radio button.</li> <li>Form these data as rows of Target Table and append these rows into Target Table.</li> </ol> <p>Now Im using two arrays to store the ID and Name that read from Source Table, but im a bit confused about how to form a row for the Target Table.</p> <pre><code>$('#btnLinkCase').click(function (event) { var caseID = $('#caseID').text(); var linkedIDArr = []; //array list for selected id var linkedNameArr = []; //array list for selected name $('#linkCaseTable tbody tr td:nth-child(2)').each(function (index, el) { //store each paire of &lt;tr&gt; into array linkedIDArr.push(el); }); $('#linkCaseTable tbody tr td:last-child').each(function (index, el) { //store each paire of &lt;tr&gt; into array linkedNameArr.push(el); }); $.each(linkedCaseIDArr, function (index, val) { //whats next? }); }); </code></pre> <p>Please see all source code <a href="http://jsfiddle.net/Rn5D2/4/" rel="nofollow noreferrer">here</a></p> <p>Any ideas of doing this? Thanks in advance</p> <p><strong>Edit</strong>: If multiple rows are selected they will use the same value from the radio button. eg: two rows are selected and "Type 1" is checked. In target table, their relationship all are "Type 1". I hope I have explained myself..</p>
 

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