Hello everyone, I'm having a conceptual breakdown... I am stuck on event handlers. The task is to click a table row (or just a cell if necessary) to trigger a routine to break out the record to display the full record set, update it, or delete it. I have tried a whole variety of traditional and modern event handlers and listeners, but as you have probably already guessed, nothing has worked. I have broken it down to the simplest possible in-element handler but still no joy.
I suspect that the problem may be the order of processing; I have learned that PHP is the first in order, so perhaps attaching event handlers to echoed HTML won't work. I'm grasping at straws here, and I hope someone can clear up the issue. I would like an explanation of the theory, not just a code fix, so the proverbial light will illuminate.
The end code will be much more involved, but here is the most basic version to simply get the onclick handler to function with a simple 'hello' alert. Why doesn't it work?
echo "<div id='wrap'>";
echo "<table id='myTable' align='center'>";
$sql="SELECT * FROM Complex ORDER BY Name" . $num;
$result = $db->query($sql);
// Column headings: The MySQL table column names
while($row = mysqli_fetch_assoc($result)) //Get Rows - Display in column format
// Table row data in table columns
echo "<tr id='myRow'><td class='link' id='myCell'><a href='#' onclick='alert('hello!')>".$row['Key_ID']." - ".$row['Name']."</td>
<td class='link'><a href='#1'>".$row['Address1']."</td>
<td class='link'><a href='#1'>".$row['Address2']."</td>
<td class='link'><a href='#1'>".$row['City']." ".$row['State']." ".$row['Zip']."</td></tr>";
} //end of function
} //end of class pagination