I am creating a table based on rows returned from a MySQL query using PHP:
while($row = mysqli_fetch_array($query_results)){
echo "<tr>";
echo "<td>$row[Title]</td>";
echo "<td>$row[Name]</td>";
echo "<td><input class='row-$i' id='one-$i' type='checkbox' ($row[check_one]==1 ? 'checked' : '')/></td>";
echo "<td><input class='row-$i' id='two-$i' type='checkbox' ($row[check_two]==1 ? 'checked' : '')/></td>";
echo "</tr>";
$i++
}
What I want to have happen is if the first checkbox is checked and you check the second one, the first checkbox becomes unchecked. I was originally going to use radio buttons to accomplish this, but the user also needs to be able to freely check or uncheck the first check box (ie both can be unchecked at one time), so radio buttons won't work. So what I need to do is detect change for two-$i elements, but am not sure how to do so for a dynamic element. Under normal circumstances the JQuery would be:
$('#two').change(function(){...});
So how can I modify this to work on the dynamic ids?
Aucun commentaire:
Enregistrer un commentaire