php - Only show one hidden table row at a time -
i have table every second table row has class name of "hideme". in css file have made .hideme { display:none}
the hidden row contains options/information row above it. goal use jquery toggle hidden row on/off when row above clicked. have succeded @ this, code has flaw. can have multiple hidden rows shown @ same time. not desirable. i'd have single hidden row shown @ given time , or none @ all.
how should change jquery code make table act want to?
this jquery code:
$(document).ready(function() { $('#eventtable tr').click(function() { $(this).closest("tr").next().toggle(); }); });
my html/php follows:
while ($row = mysqli_fetch_array($r, mysqli_assoc)) { echo ' <tbody> <tr> <td>' . $row['event'] . '</td> <td>' . $row['dr'] . '</td> </tr> <tr class = "hideme"> <form method="post" action="galleryhandler.php"> <input type="hidden" name="name" value="' . $row['name'] . '" /> <td><input type="password" class="input" name="password" size="25" maxlength="20"/></td> <td><input type="submit" name="submit" value="se fotosession" class="button2"/></td> </form> </tr> </tbody> '; }
the problem has been solved kind stackoverflow user. still have problem because have text fields in hidden rows, didn't mention @ first, , disappear when clikc on them.
this trick:
$(document).ready(function() { $('#eventtable tr:even').on('click', function() { if ($(this).next().css('display') == 'none') { $('#eventtable .hideme').hide(); $(this).next().show(); } else { $('#eventtable .hideme').hide(); } }); });
working here:
this make toggle behaviour work, close whichever 1 open before opening 1 you've clicked.
Comments
Post a Comment