Capture Same Row HTML Tag Under Table

Capture Same Row HTML Tag Under Table

Hi Guys,

Here's what I have so far.

   
As you can see those were generated with this codes:

  1. <table class="table_format">
  2. <tr id="header_name">
  3. <th>Status</th>
  4. <th>ID</th>
  5. <th>Name</th>
  6. <th>Job Title</th>
  7. <th>Job Code</th>
  8. <th>Cost Ctr</th>
  9. <th>Country</th>
  10. <th>Tower</th>
  11. <th>Team</th>
  12. <th>Hire Date</th>
  13. <th>Email</th>
  14. <th>NT ID</th>
  15. <th>Sup Name</th>
  16. </tr>
  17. <?php
  18. $query = "SELECT * FROM tb_active WHERE sup_name = '$user_id'";
  19. $result = mysqli_query($con, $query);
  20. while($row = mysqli_fetch_assoc($result)) {
  21. $status_nameX = $row["status_name"];
  22. $assoc_id = $row["assoc_id"];
  23. $full_name = $row["full_name"];
  24. $job_title = $row["job_title"];
  25. $job_code = $row["job_code"];
  26. $cost_ctr = $row["cost_ctr"];
  27. $country = $row["country"];
  28. $tower = $row["tower"];
  29. $team = $row["team"];
  30. $rehire_date = $row["rehire_date"];
  31. $email = $row["email"];
  32. $nt_id = $row["nt_id"];
  33. $sup_name = $row["sup_name"];
  34. ?>
  35. <tr class="field_row">
  36. <?php
  37. $query_status_name = "SELECT * FROM tb_status ORDER BY status_name ASC";
  38. $result_status_name = mysqli_query($con, $query_status_name);
  39. ?>
  40. <td>
  41. <select class="status_name_class" style="width:90px">
  42. <option value="<?php echo $status_name;?>" selected="selected"><?php echo $status_nameX;?></option>
  43. <?php
  44. while($row = mysqli_fetch_assoc($result_status_name)) {
  45. $row_id = $row["row_id"];
  46. $status_name = $row["status_name"];
  47. if ($status_name != $status_nameX) {
  48. ?>
  49. <option value="<?php echo $row_id;?>"><?php echo $status_name;?></option>
  50. <?php
  51. }
  52. }
  53. ?>
  54. </select>
  55. </td>
  56. <td><input type="text" value="<?php echo $assoc_id;?>" style="width: 50px" class="assoc_id_class"/></td>
  57. <td><input type="text" value="<?php echo $full_name;?>"style="width: 150px" class="full_name_class"/></td>
  58. <td><input type="text" value="<?php echo $job_title;?>" style="width: 150px" class="job_title_class"/></td>
  59. <td><input type="text" value="<?php echo $job_code;?>" style="width: 90px" class="job_code_class"/></td>
  60. <td><input type="text" value="<?php echo $cost_ctr;?>" style="width: 90px" class="cost_ctr_class"/></td>
  61. <td><input type="text" value="<?php echo $country;?>" style="width: 60px" class="country_class"/></td>
  62. <td><input type="text" value="<?php echo $tower;?>" style="width: 70px" class="tower_class"/></td>
  63. <td><input type="text" value="<?php echo $team;?>" style="width: 220px" class="team_class"/></td>
  64. <td><input type="text" value="<?php echo $rehire_date;?>" style="width: 70px" class="rehire_date_class"/></td>
  65. <td><input type="text" value="<?php echo $email;?>" class="email_class" style="width: 90px"/></td>
  66. <td><input type="text" value="<?php echo $nt_id;?>" style="width: 60px" class="nt_id_class"/></td>
  67. <td><input type="text" value="<?php echo $sup_name;?>" style="width:130px" class="sup_name_class"/></td>
  68. </tr>
  69. <?php
  70. }
  71. ?>
  72. </table>
Bunch of td's on while loop from the database.

What I want to achieve is when I click the drop down box an choose an option I want to grab the ID.

Ex. When I choose row 2 and changed the status to Suspended I want to alert the ID right beside it. 
Output should be "58655"

jQuery so far:
  1. $(".status_name_class").change(function() {
  2. var status_update = $("option:selected", this).text();
  3. var id_assoc = $(".assoc_id_class").val();
  4. alert (id_assoc);
  5. });



Purpose: So I can use AJAX and update the status.