title: Prevent Duplicate Append data in JavaScript and Html
body: <p>I have one HTML table and I don't want the value of second column to repeat in the grid.
  Here is my JavaScript:</p>
  <pre><code>var $addedProductCodes = [];
  
  function getProductData(value){
  
          $td_productCode=$(&quot;#sales-product-code&quot;).val();
          var index = $.inArray($td_productCode, $addedProductCodes);
          if (index &gt;= 0) {
                  alert(&quot;You already added this Product&quot;);
              } else {
                  $('#test').append(&quot;&lt;tr&gt;&lt;td&gt;&quot;+ value +&quot;&lt;/td&gt;&lt;/tr&gt;&quot;);
                  $addedProductCodes.push($td_productCode);
              }
          }
  </code></pre>
  <p>and Html</p>
  <pre><code>    &lt;tbody  id=&quot;test&quot;&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;input type=&quot;text&quot; id=&quot;sales-product-code&quot; name=&quot;cm_code[]&quot; value=&quot;&quot; class=&quot;sales-product-code&quot;/&gt; &lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
  </code></pre>
  <p>Please help me out. Help is highly appreciated.</p>