title: How to choose only one row at a time in html table using javascript
body: <p>I want to choose only one row at a time from html table... Im using php,html and javascript.. if i choose one row means that the value only show in alert box at a time using javascript.. 
   I wrote some js coding but it shows all the row values one by one in alertbox.. Please anyone help for me..</p>
  
  <p>My html code:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;table BORDER="5"&gt;
                      &lt;tr&gt;
                          &lt;th colspan="10"&gt;
                             
                              
                          &lt;/th&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;th&gt;Date &amp; Time&lt;/th&gt;
                          &lt;th&gt;Name&lt;/th&gt;
                          &lt;th&gt;Source&lt;/th&gt;
                          &lt;th&gt;Destination&lt;/th&gt;
                          &lt;th&gt;Ride Type&lt;/th&gt;
                          &lt;th&gt;Vehicle Type&lt;/th&gt;
                          &lt;th&gt;Plate No.&lt;/th&gt;
                          &lt;th&gt;Distance&lt;/th&gt;
                 &lt;/tr&gt;
                       &lt;?php $search_data = "";?&gt;
                      &lt;tbody id="table"style="cursor:pointer"onclick="found(this);"&gt;
                      &lt;tr id="choose"&gt;
                      
                              &lt;?php echo $search_data; ?&gt;
                              
                              &lt;/tr&gt;
                      &lt;/tbody&gt;
                        
                  &lt;/table&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>My javascript:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function found(row) {
       //alert("hai");
       var table=document.getElementById("table");
       var cells = table.getElementsByTagName("tr");
       for (var i = 0; i &lt; cells.length; i++) {
       alert(cells[i].innerHTML);
  }
       
      }</code></pre>
  </div>
  </div>
  </p>
  
  <p>My php code:
  while ($data = mysql_fetch_array($firstattempt)) 
              {</p>
  
  <pre><code>        $search_data = "";
         $search_data .= "&lt;tr&gt;";
              $search_data .= "&lt;td&gt;{$data["DATE"]} &amp; {$data["START_TIME"]}&lt;/td&gt;";
              $search_data .= "&lt;td&gt;{$data["NAME"]}&lt;/td&gt;";             
              $search_data .= "&lt;td&gt;{$data["START_FROM"]}&lt;/td&gt;";
              $search_data .= "&lt;td&gt;{$data["END_TO"]}&lt;/td&gt;";
              $search_data .= "&lt;td&gt;{$data["RIDER_FLAG"]}&lt;/td&gt;";
              $search_data .= "&lt;td&gt;{$data["VEHICLE_TYPE"]}&lt;/td&gt;";
              $search_data .= "&lt;td&gt;{$data["PLATE_NO"]}&lt;/td&gt;";
              $search_data .= "&lt;td&gt;{$distance} Km&lt;/td&gt;";
  
              $search_data .= "&lt;/tr&gt;";
              echo $search_data;
  
    }
  </code></pre>
  
  <p>My output :
  <img src="https://i.stack.imgur.com/RNp8E.jpg" alt="output"></p>