Jump to content

Display Data Issue


ainoy31

Recommended Posts

I am trying to show and hide data from a table and having an issue with it.  It is only displaying the first row.  Here is my javascript:

function toggle(id)
{
//document.write(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 the rest of the 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('<?=$j?>');"></td>
    		<td class="done"><?php print $results[$j]->database ?></td>
    		<td class="done"><?php print $results[$j]->table ?></td>
  	</tr>
<tr>
	<td>

		<?
		foreach($results[$j]->info as $key => $value)
		{
  			?>	
			<tr id="<?=$j;?>" style="display: none;">
    				<td style="background-color: #95FE3F;"><?=$key;?></td>			
    				<td style="background-color: #95FE3F;"><?=$value;?></td>
			<td style="background-color: #95FE3F;"> </td>
			</tr>
	      <?}?>

	</td>
</tr>	
<?php 
} 
?>
</table>

 

I have attached a screen shot of what it is displaying after clicking on the checkbox as well as what I need it to do.  Much appreciation on any help.  Thanks.  AM

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/156136-display-data-issue/
Share on other sites

I figured it out.  Here is my solution. 

 

<td>

<tr id="<?=$j;?>" style="display: none;">

<td colspan="3" style="background-color: #95FE3F;">

<?

foreach($results[$j]->info as $key => $value)

{

  echo $key . ' - ' . $value . "<br>";

 

        }?>

</td>

</tr>

</td>

Link to comment
https://forums.phpfreaks.com/topic/156136-display-data-issue/#findComment-821917
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.