sheriff Posted June 14, 2007 Share Posted June 14, 2007 Hi all .. can anyone help me out with this ? I have a php generated table. ---------------------------- | | row 1 | onclick on row1 shows up description 1, oncick again on row1, hide description 1. ---------------------------- | | description row 1 | ---------------------------- | | row 2 | ---------------------------- | | description row 2 | ---------------------------- | | row 3 | ---------------------------- | | description row 3 | ---------------------------- | I want something with onClick="showhide(???)" by <td id="<?php echo row['pr_id'] ?>"> a similar style is at http://isohunt.com/torrents/?ihq=Joe+Satriani thanks for help! Quote Link to comment https://forums.phpfreaks.com/topic/55637-solved-show-hide-rows-by-id/ Share on other sites More sharing options...
akitchin Posted June 14, 2007 Share Posted June 14, 2007 this is actually more javascript than it is PHP. you need to define a DIV with an id that is unique to that row, and pass this id to the showhide() function which will change its visibility and/or display properties: while ($blah = mysql_fetch_array($blah)) { echo '<tr><td onclick="javascript:switch_div(\''.$blah['id'].'\');>row1<div id="row_number_'.$blah['id'].'">Description</div></td></tr>"; } syntax is a little tricky when you have to play with different quotes, but that's worth a shot. you'll have to write switch_div() yourself, but i assume you know how to do that. Quote Link to comment https://forums.phpfreaks.com/topic/55637-solved-show-hide-rows-by-id/#findComment-274914 Share on other sites More sharing options...
sheriff Posted June 14, 2007 Author Share Posted June 14, 2007 I solved it somehow ... <html> <head> <script> function on(i) { document.getElementById(i).className="show"; } function off(i){ document.getElementById(i).className="hide"; } </script> </head> <body> .... php/mysql stuff .... <tr> <td align="center" width="30"><span class="cn_text"><?php echo $row_nr++; ?></span></td> <td width="40" <span class="cn_text"> <?php echo $row['pr_code']; ?></span></td> <td width="150" onmouseover="on('<?php echo $row['pr_id']; ?>')" onmouseout="off('<?php echo $row['pr_id']; ?>')"><span class="cn_text"> <?php echo $row['pr_name']; ?> </span></td> <td width="200" bgcolor="<?php echo $row_color; ?>"><span class="cn_text"> <?php echo $row['pr_desc_tech']; ?></span></td> <td <span class="cn_text"> <?php echo $row['pr_price']; ?> RON</span></td></tr> <tr id="<?php echo $row['pr_id']; ?>"> <td colspan="5" bgcolor="<?php echo $row_color; ?>"><span class="cn_text"> <?php echo $row['pr_desc_expl']; ?></span></td> </tr> <?php } ?> </table> </body> Thanks anyway for help ! Quote Link to comment https://forums.phpfreaks.com/topic/55637-solved-show-hide-rows-by-id/#findComment-274921 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.