Jump to content

[SOLVED] show hide rows by id !?


sheriff

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/55637-solved-show-hide-rows-by-id/
Share on other sites

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.

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 !

 

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.