Jump to content

[SOLVED] Show and Hide data in a table


ainoy31

Recommended Posts

I dynamicly populate a table from a DB.  I am need to hide one column's full text display during page loading but there is an option to click and expand to view the text. 

 

Here is my JS

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 code to populate the table

while($row = mysql_fetch_array($result))
{
	extract($row);
	$desc = substr($description,0,75);
?>
<tr>
	<td style="text-align:center"><a style="text-decoration:none" href="javascript:void(0);" onclick="window.open('edit_error.php?el=<?=$event_id;?>', '', 'width=400, height=250, scrollbars=no')" href='' class='CT'><?=$error_level;?> [Edit]</a></td>
	<td style="text-align:center"><?=$sessionid;?></td>
	<td><?=$insert_date;?></td>
	<td>
		<a onclick="toggle('$event_id');" href="#" style="text-decoration:none">[+]  </a><?=$desc;?>
		<span id="$event_id" style="Display:none"><?=$description;?></span>
	</td>
	<td><?=$ip_address;?></td>
	<td><?=$browser;?></td>
	<td><?=$filename;?></td>
</tr>
      <?}?>

 

 

 

The problem is that I can click on the first item to expand and read the text but when I click on other ones, it refers back to the vry first one.  I hope this makes sense.  I attached an image as well.  Much appreciation.  AM

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/155088-solved-show-and-hide-data-in-a-table/
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.