Better row click handling
This commit is contained in:
21
tower.php
21
tower.php
@@ -120,6 +120,7 @@ require_db_auth();
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
<center><h2>Swansea Inbound PPR <?php echo date('l d M Y'); ?></h2></center>
|
||||
|
||||
@@ -149,7 +150,7 @@ $result = $conn->query($sql);
|
||||
// Check if there are results
|
||||
if ($result->num_rows > 0) {
|
||||
// Start HTML table
|
||||
echo '<table border="1">
|
||||
echo '<table border="1" id="entries">
|
||||
<thead>
|
||||
<tr>';
|
||||
|
||||
@@ -169,7 +170,7 @@ if ($result->num_rows > 0) {
|
||||
|
||||
// Output table rows
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
echo '<tr onclick="openDetail(' . $row['id'] . ')">';
|
||||
echo '<tr data-id=' . $row['id'] . '>';
|
||||
foreach ($row as $key => $value) {
|
||||
if ($key != 'id' && $key != 'ac_call') {
|
||||
if ($key == 'ac_reg' && $row['ac_call'] != NULL) {
|
||||
@@ -199,4 +200,18 @@ $conn->close();
|
||||
function openPopup() {
|
||||
window.open("input.html", "PopupWindow", "toolbar=no, location=no, directories=no,status=no, menubar=no, scrollbars=yes, resizable=yes, copyhistory=yes, width=600, height=1100");
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
document.getElementById("entries").addEventListener("click", function (event) {
|
||||
let td = event.target.closest("td");
|
||||
if (!td) return; // Clicked outside <td>
|
||||
|
||||
let tr = td.parentElement; // Get the row
|
||||
|
||||
if (td !== tr.lastElementChild) {
|
||||
let rowId = tr.dataset.id; // Get the unique row ID
|
||||
openDetail(rowId);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user