I am trying to extract a particular column value and wrote this code with the help of this [link](http://jsfiddle.net/arunpjohny/8TNra/). But messed up somewhere/ or missing some concept.

Any guidance would help. The code follows 

**HTML**

```
<tr class="findVal">
<?php
    include("myIncludeFile");

    $result = mysql_query("myQuery");
    while($test = mysql_fetch_array($result))
    {
        echo "<td class=".'hidden-phone hidden-tablet hidden-desktop id'.">".$test['col_nm1']."</td>";
       /*Other table data from database
       ..............................*/ 
       echo"<td>".'<div class="checkbox">
            <label><input type="checkbox" name="total" id ="total" value="'.$test['col_nm2'].'"">'.$test['col_nm2'].'</label>
         </div>'."</td>";
       echo"<td>".'<button type="submit" id="approve" class="btn btn-success" onclick="checkTotal()">Approve</button>'."</td>";
       echo "</tr>";
    }
    mysql_close($conn);
?>
</tr>

```

**JS**

```
<script type="text/javascript">
    function checkTotal() {

        var tr = $(this).closest('.findVal');
        var findID = tr.find('.id').text();
        alert(findID);

  }
</script>

```

N.B :[![enter image description here](https://i.stack.imgur.com/jXjNv.png)](https://i.stack.imgur.com/jXjNv.png)