It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

Javascript Show/Hide in PHP Loop problem

Javascript Show/Hide in PHP Loop problem

Postby koolsamule on Thu Sep 03, 2009 11:34 am

Hi Guys,

I have a PHP loop region, which repeats all completed projects for each customer, then displays all jobsheets linked to those projects.
I have a javascript show/hide function, which will only show the jobsheets when the project link is clicked.
Without this javascript, the PHP loop works perfectly, but all the information is displayed. How can I use the show/hide function and still show all the jobsheets for completed projects?
Code: Select all
function toggle2(id, link) {
  var e = document.getElementById(id);

  if (e.style.display == '') {
    e.style.display = 'none';
    link.innerHTML = '<img src="../Images/plus.gif" border="0" >';
  } else {
    e.style.display = '';
    link.innerHTML = '<img src="../Images/minus.gif" border="0" >';
  }
}

Code: Select all
<table>
<tr>
<th>Project / Job</th>
<th>Language</th>
<th>Words (Net)</th>
<th>Shipped</th>
</tr>

<?php
$previousProject = '';
if ($totalRows_rsComplete_Cust > 0) {
// Show if recordset not empty
while ($row_rsComplete_Cust = mysql_fetch_assoc($rsComplete_Cust)) {
if ($previousProject != $row_rsComplete_Cust['projid']) {
// for every user, show the user name
?>

<tr>
<td colspan="4"><a href="#" onclick="toggle2('<?php echo $row_rsComplete_Cust['projid']; ?>', this)"><img src="../Images/plus.gif" border="0" /></a><?php echo $row_rsComplete_Cust['projid']; ?></td>
</tr>

<?php $previousProject = $row_rsComplete_Cust['projid']; } ?>

<tr id="<?php echo $row_rsComplete_Cust['projid']; ?>" style="display:none">
<td><a href="jobsheet_details.php?id=<?php echo $row_rsComplete_Cust['jobid']; ?>&amp;proj=<?php echo $row_rsComplete_Cust['projid']; ?>"><?php echo $row_rsComplete_Cust['jobname']; ?></a></td>
<td>LANGUAGE</td>
<td>WORD NET</td>
<td>YES / NO</td>
</tr> 

<?php }} // Show if recordset not empty ?>

</table>
koolsamule
 
Posts: 8
Joined: Thu Sep 03, 2009 11:32 am

Who is online

Users browsing this forum: No registered users and 2 guests