title: How to get the Table Ids and the Value on clicking a row element in a particular column from multiple tables?
body: <p>I need some help to write a javascript function to retrieve the clicked value as well as the table id upon clicking a particular column(Tier) from multiple tables.</p>
  <p>For example, when I click on Tier 1, I am trying to assign it to tier_token and set the client based on the table id --&gt; tier_token=Tier 1, client=products.
  If I click on Tier 2 , tier_token=Tier 1, client=products .
  If I click on Tier 1 from the customers' table, tier_token=Tier 1 and client=customers, and so on.</p>
  <p>In my script, I have been using <code>document.getElementById</code>, I would like to have something which I could use for multiple table ids at the same time, retrieve that id value, and set it to the variable client - because although I have listed just a couple of tables, I need to define multiple tables later.</p>
  <p>Also, I would like to allow the clicks only on the Tier column and prevent the clicks on the Points column.</p>
  <pre><code>&lt;html&gt;
  &lt;table class=&quot;table&quot; id=&quot;products&quot;&gt;
  &lt;tr&gt;
      &lt;th&gt;Tier&lt;/th&gt;
      &lt;th&gt;Points&lt;/th&gt;
  &lt;/tr&gt;
      &lt;tr&gt;
      &lt;td&gt;Tier1&lt;/td&gt;
      &lt;td&gt;0&lt;/td&gt;
    &lt;/tr&gt;
     &lt;tr&gt;
      &lt;td&gt;Tier2&lt;/td&gt;
      &lt;td&gt;10&lt;/td&gt;
    &lt;/tr&gt;
     &lt;tr&gt;
      &lt;td&gt;Tier3&lt;/td&gt;
      &lt;td&gt;100&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/table&gt;
   
    &lt;table class=&quot;table&quot; id=&quot;customers&quot;&gt;
     &lt;tr&gt;
      &lt;th&gt;Tier&lt;/th&gt;
      &lt;th&gt;Points&lt;/th&gt;
     &lt;/tr&gt;
      &lt;tr&gt;
      &lt;td&gt;Tier1&lt;/td&gt;
      &lt;td&gt;10&lt;/td&gt;
    &lt;/tr&gt;
     &lt;tr&gt;
      &lt;td&gt;Tier2&lt;/td&gt;
      &lt;td&gt;20&lt;/td&gt;
    &lt;/tr&gt;
     &lt;tr&gt;
      &lt;td&gt;Tier3&lt;/td&gt;
      &lt;td&gt;500&lt;/td&gt;
    &lt;/tr&gt;
     &lt;tr&gt;
      &lt;td&gt;Tier4&lt;/td&gt;
      &lt;td&gt;21&lt;/td&gt;
    &lt;/tr&gt;
    &lt;/table&gt;
  &lt;/html&gt;
  </code></pre>
  <p>Script:</p>
  <pre><code>&lt;script&gt;
  var table = document.getElementById(&quot;customers&quot;);
      if (table != null) {
          for (var i = 1; i &lt; table.rows.length; i++) {
              for (var j = 0; j &lt; table.rows[i].cells.length; j++)
              table.rows[i].cells[j].onclick = function () {
                  tableText(this);
              };
          }
      }
      function tableText(tableCell) {
          //alert(tableCell.innerHTML);
          var tier_token=tableCell.innerHTML;
          var client = &quot;customers&quot;;
          console.log(&quot;Tier:&quot;+ tier_token);
          console.log(&quot;Client:&quot;+ client);
          alert(&quot;Tier:&quot;+ tier_token + &quot;Client:&quot;+ client);
      }
  
  &lt;/script&gt;
  
  </code></pre>