Jump to content

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 !

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.