Wenn ich eine Tabelle mit mehreren Zeilen habe und jede Zeile das gleiche Auswahlfeld hat, wie würde ich den Wert des ausgewählten Dropdowns erhalten? Ich bekomme momentan nur den ersten Wert in der ersten Reihe, egal welche Reihe ich auswähle.Wie wähle ich einen Wert in einem Dropdown in einer Tabelle aus?
<form action="<?php echo $_POST['PHP_SELF'] ; ?>" method="post">
<table class="radius" id="drTable">
<tr>
<th><a href="index.php?page=donation-requests&order_by=a.dr_id&order_direction=<?php if($order_direction == "ASC") { echo "DESC" ; } else { echo "ASC" ; } ?>">ID</a></th>
<th><a href="index.php?page=donation-requests&order_by=a.lastname&order_direction=<?php if($order_direction == "ASC") { echo "DESC" ; } else { echo "ASC" ; } ?>">Name</a></th>
<th><a href="index.php?page=donation-requests&order_by=d.location&order_direction=<?php if($order_direction == "ASC") { echo "DESC" ; } else { echo "ASC" ; } ?>">Store</a></th>
<th><a href="index.php?page=donation-requests&order_by=a.organization&order_direction=<?php if($order_direction == "ASC") { echo "DESC" ; } else { echo "ASC" ; } ?>">Organization</a></th>
<th><a href="index.php?page=donation-requests&order_by=a.event_name&order_direction=<?php if($order_direction == "ASC") { echo "DESC" ; } else { echo "ASC" ; } ?>">Event Name</a></th>
<th><a href="index.php?page=donation-requests&order_by=a.event_date&order_direction=<?php if($order_direction == "ASC") { echo "DESC" ; } else { echo "ASC" ; } ?>">Event Date</a></th>
<th><a href="index.php?page=donation-requests&order_by=a.date_required&order_direction=<?php if($order_direction == "ASC") { echo "DESC" ; } else { echo "ASC" ; } ?>">Date Needed By</a></th>
<th><a href="index.php?page=donation-requests&order_by=a.date_requested&order_direction=<?php if($order_direction == "ASC") { echo "DESC" ; } else { echo "ASC" ; } ?>">Date Requested</a></th>
<th><a href="index.php?page=donation-requests&order_by=c.status&order_direction=<?php if($order_direction == "ASC") { echo "DESC" ; } else { echo "ASC" ; } ?>">Status</a></th>
<th class="text-center">View/Edit</th>
<th class="text-center">Delete</th>
</tr>
<?php
while($row = $result->fetch()) {
?>
<tr>
<td><?php echo $row['dr_id'] ; ?></td>
<td><?php echo $row['lastname'].", ".$row['firstname'] ; ?></td>
<td><?php echo $row['location'] ; ?></td>
<td><?php echo $row['organization'] ; ?></td>
<td><?php echo $row['event_name'] ; ?></td>
<td><?php echo date("F j, Y", $row['event_date']) ; ?></td>
<td><?php echo date("F j, Y", $row['date_required']) ; ?></td>
<td><?php echo date("F j, Y", $row['date_requested']) ; ?></td>
<td>
<select class="radius" onchange="updateStatus(<?php echo $row['dr_id']; ?>);">
<option selected="true" disabled="disabled"><?php echo $row['status'];?></option>
<?php echo statusOptions($row['status']) ; ?>
</select>
</td>
<td class="text-center"> <a href="index.php?page=donation-requests-edit&viewing_id=<?php echo $row['dr_id'] ; ?>&status=<?php echo $_GET['status'] ; ?>"><i class="fi-pencil size-24"></i></a></td>
<td class="text-center"><a href="#" onClick="deleteRequest(<?php echo $row['dr_id'] ; ?>)"><i class="fi-trash size-24"></i></a></td>
</tr>
<?php
}
?>
</table>
</form>
jquery:
function updateStatus(dr_id) {
var id = dr_id;
$.ajax({ //create an ajax request to load_page.php
type: "GET",
// url: "drStatus_update.php?id="+id+"&status="+status,
dataType: "html", //expect html to be returned
success: function(response){
//alert(response);
alert(status);
}
});
}
Wir benötigen etwas von Ihrem Codebeispiel, um zumindest zu wissen, wo das Problem liegt. –
Verwenden Sie den [': eq()'] (https://api.jquery.com/eq-selector/) Selektor, um dies zu tun. – Mohammad