ainoy31 Posted April 28, 2009 Share Posted April 28, 2009 I need help to show and hide my data on a table. If they check the box, it will display the data under the selected row. Here is my JS for the toggle function. function toggle(id) { var state = document.getElementById(id).style.display; if(state == 'block') { document.getElementById(id).style.display = 'none'; } else { document.getElementById(id).style.display = 'block'; } } Here is my html/php code <table class="tableresult"> <tr valign="TOP" align="left" nowrap="nowrap"> <th nowrap="nowrap"> </th> <th nowrap="nowrap">Database</th> <th nowrap="nowrap">Table</th> </tr> <?php for($j=0; $j<count($results); $j++){ ?> <tr valign="TOP" align="left" nowrap="nowrap"> <td class="done"><input type="checkbox" onclick="toggle('<?=$results[$j]->info;?>')"></td> <td class="done"><?php print $results[$j]->database ?></td> <td class="done"><?php print $results[$j]->table ?> </tr> <? foreach($results[$j]->info as $key => $value) { ?> <tr><div id="<?=$value;?>" style="display: none;"> <td style="background-color: #95FE3F;"><?=$key;?></td> <td style="background-color: #95FE3F;"><?=$value;?></td> <td style="background-color: #95FE3F;"> </td> </div> </tr> <?}//end of foreach($results[$j] as $key => $value)?> <?php } ?> </table> It is not hiding the results. Attached my output. Much appreciation. AM [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/156025-solved-toggle-with-show-and-hide/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.