ainoy31 Posted April 21, 2009 Share Posted April 21, 2009 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 More sharing options...
soak Posted April 21, 2009 Share Posted April 21, 2009 make both instances of: $event_id into <?= $event_id ?> Link to comment https://forums.phpfreaks.com/topic/155088-solved-show-and-hide-data-in-a-table/#findComment-815760 Share on other sites More sharing options...
ainoy31 Posted April 21, 2009 Author Share Posted April 21, 2009 Thanks for that. I need to go to bed after that stupid miss. Later man. Thanks Soak. Link to comment https://forums.phpfreaks.com/topic/155088-solved-show-and-hide-data-in-a-table/#findComment-815767 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.