Note that there are some explanatory texts on larger screens.

plurals
  1. POComparing 2 tables column values and copying the next column content to the second table
    primarykey
    data
    text
    <p>I am comparing between two tables first column each. If there is find a match i am copying the text from the adjacent cell of the first table to the second table. I am able to compare strings and get the value, but finding it difficult to print it in the second table. I am getting the value in the var "replaceText", but how to print it in the second table ?? Please help... Sample code is as follows..</p> <pre><code>&lt;script type="text/javascript"&gt; jQuery.noConflict(); jQuery(document).ready(function(){ jQuery('.itemname').each(function(){ var itemName = jQuery(this).text(); jQuery('.comparerow').each(function() { var compareRow = jQuery(this).text(); if (itemName == compareRow) { var replaceText = jQuery(this).next('td').text(); alert(replaceText); } }); }); }); &lt;/script&gt; </code></pre> <p>HTML is as follows</p> <pre><code>&lt;table width="100%"&gt;&lt;thead&gt; &lt;tr&gt; &lt;th align="left" &gt;Name&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt;&lt;/tr&gt;&lt;/thead&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td class="comparerow"&gt;IX0001&lt;/td&gt; &lt;td class="desc"&gt;Desc 1 &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="comparerow"&gt;IX0002&lt;/td&gt; &lt;td class="desc" &gt;Desc 2 &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="comparerow"&gt;IX0003&lt;/td&gt; &lt;td class="desc"&gt;Desc 3 &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="comparerow"&gt;IX0004&lt;/td&gt; &lt;td class="desc"&gt;Desc 4 &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;br /&gt; &lt;table width="100%"&gt; &lt;tr&gt; &lt;th&gt;Name&lt;/th&gt;&lt;th&gt;Description&lt;/th&gt; &lt;/tr&gt; &lt;tr &gt; &lt;td class="itemname"&gt;IX0001&lt;/td&gt;&lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="itemname"&gt;IX0002&lt;/td&gt;&lt;td&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="itemname"&gt;IX0003&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.
 

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