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:
- <table class="table_format">
- <tr id="header_name">
- <th>Status</th>
- <th>ID</th>
- <th>Name</th>
- <th>Job Title</th>
- <th>Job Code</th>
- <th>Cost Ctr</th>
- <th>Country</th>
- <th>Tower</th>
- <th>Team</th>
- <th>Hire Date</th>
- <th>Email</th>
- <th>NT ID</th>
- <th>Sup Name</th>
- </tr>
- <?php
- $query = "SELECT * FROM tb_active WHERE sup_name = '$user_id'";
- $result = mysqli_query($con, $query);
-
- while($row = mysqli_fetch_assoc($result)) {
- $status_nameX = $row["status_name"];
- $assoc_id = $row["assoc_id"];
- $full_name = $row["full_name"];
- $job_title = $row["job_title"];
- $job_code = $row["job_code"];
- $cost_ctr = $row["cost_ctr"];
- $country = $row["country"];
- $tower = $row["tower"];
- $team = $row["team"];
- $rehire_date = $row["rehire_date"];
- $email = $row["email"];
- $nt_id = $row["nt_id"];
- $sup_name = $row["sup_name"];
-
- ?>
- <tr class="field_row">
- <?php
- $query_status_name = "SELECT * FROM tb_status ORDER BY status_name ASC";
- $result_status_name = mysqli_query($con, $query_status_name);
- ?>
- <td>
- <select class="status_name_class" style="width:90px">
- <option value="<?php echo $status_name;?>" selected="selected"><?php echo $status_nameX;?></option>
- <?php
- while($row = mysqli_fetch_assoc($result_status_name)) {
- $row_id = $row["row_id"];
- $status_name = $row["status_name"];
- if ($status_name != $status_nameX) {
- ?>
- <option value="<?php echo $row_id;?>"><?php echo $status_name;?></option>
- <?php
- }
- }
- ?>
- </select>
- </td>
-
- <td><input type="text" value="<?php echo $assoc_id;?>" style="width: 50px" class="assoc_id_class"/></td>
- <td><input type="text" value="<?php echo $full_name;?>"style="width: 150px" class="full_name_class"/></td>
- <td><input type="text" value="<?php echo $job_title;?>" style="width: 150px" class="job_title_class"/></td>
- <td><input type="text" value="<?php echo $job_code;?>" style="width: 90px" class="job_code_class"/></td>
- <td><input type="text" value="<?php echo $cost_ctr;?>" style="width: 90px" class="cost_ctr_class"/></td>
- <td><input type="text" value="<?php echo $country;?>" style="width: 60px" class="country_class"/></td>
- <td><input type="text" value="<?php echo $tower;?>" style="width: 70px" class="tower_class"/></td>
- <td><input type="text" value="<?php echo $team;?>" style="width: 220px" class="team_class"/></td>
- <td><input type="text" value="<?php echo $rehire_date;?>" style="width: 70px" class="rehire_date_class"/></td>
- <td><input type="text" value="<?php echo $email;?>" class="email_class" style="width: 90px"/></td>
- <td><input type="text" value="<?php echo $nt_id;?>" style="width: 60px" class="nt_id_class"/></td>
- <td><input type="text" value="<?php echo $sup_name;?>" style="width:130px" class="sup_name_class"/></td>
- </tr>
-
- <?php
- }
- ?>
- </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:
- $(".status_name_class").change(function() {
- var status_update = $("option:selected", this).text();
- var id_assoc = $(".assoc_id_class").val();
- alert (id_assoc);
- });
Purpose: So I can use AJAX and update the status.