2011-03-30 94 views
0

我有一個表格顯示我的搜索結果,並等待如果用戶有一個功能打開我想只顯示每行5個結果,如果相同他們已關閉我想顯示7個結果。這工作正常,但我遇到的問題是當我切換功能的div是隱藏或顯示,但動態創建的PHP內容仍然可見。我知道div隱藏或顯示等待函數,因爲我在動態創建div中寫入靜態文本,並等待函數顯示或隱藏文本。使用jquery隱藏和顯示php動態創建的內容「搜索結果」

問題:如何隱藏php的內容呢? PHP內容=

/*BIG*/ 
    //begin new row 
    if($result_incBig == $beginRowBig){ 
     $b .= '<tr>'; 
     //row color 
     $row_color = ($color_incBig % 2) ? 'tdAltRow_A' : 'tdAltRow_B'; 
     if($i == ($num_qk-1)){ 
      $secondRowClass = 'tdAltRow_noBorder'; 
     }else{ 
      $secondRowClass = 'tdAltRow'; 
     } 
     //increment the color of the row 
     ++$color_incBig;     
    } 
    $b .= '<td class="td_formTitle_noBorder" align="center" style="padding:0px; text-indent: 0;" width="165" height="115" valign="bottom">'; 
     $b .= '<table width="100%" cellpadding="0" cellspacing="0" border="0">'; 
      $b .= '<tr>'; 
       $b .= '<td align="center" style="height:80px; padding:4px; vertical-align:middle;">'.$appendLinkBegin.$companyPic.$appendLinkEnd.'</td>'; 
      $b .= '</tr>'; 
      $b .= '<tr>'; 
       $b .= '<td align="center" style="height:35px; padding:2px; vertical-align:bottom;">'.$appendLinkBegin.'<b>'.$company_name.'</b>'.$addSpace.'<br />'.$num2.' '.$resultText.$appendLinkEnd.'</td>'; 
      $b .= '</tr>'; 
     $b .= '</table>'; 
    $b .= '</td>'; 
    //end row if out of results or reached max num for row 
    if($result_incBig == $endRowBig){ 
     $b .= '</tr>'; 
     $result_incBig = 0; 
    }else if(($i+1) == $num_qk){ 
     if($result_incBig < $endRowBig){ 
      for($e=0;$e<=($endRowBig-$result_incBig);++$e){ 
       $b .= '<td class="td_formTitle_noBorder" align="center" style="padding:0px; text-indent: 0;" width="165" height="115" valign="bottom"><!--space--></td>'; 
      } 
      $b .= '</tr>'; 
      $result_incBig = 0; 
     } 
    } 
    //increment inc 
    ++$result_incBig; 
    /*END BIG*/ 

    /*SMALL*/ 
    //begin new row 
    if($result_incSmall == $beginRowSmall){ 
     $s .= '<tr>'; 
     //row color 
     $row_color = ($color_incSmall % 2) ? 'tdAltRow_A' : 'tdAltRow_B'; 
     if($i == ($num_qk-1)){ 
      $secondRowClass = 'tdAltRow_noBorder'; 
     }else{ 
      $secondRowClass = 'tdAltRow'; 
     } 
     //increment the color of the row 
     ++$color_incSmall;    
    } 
    $s .= '<td class="td_formTitle_noBorder" align="center" style="padding:0px; text-indent: 0;" width="165" height="115" valign="bottom">'; 
     $s .= '<table width="100%" cellpadding="0" cellspacing="0" border="0">'; 
      $s .= '<tr>'; 
       $s .= '<td align="center" style="height:80px; padding:4px; vertical-align:middle;">'.$appendLinkBegin.$companyPic.$appendLinkEnd.'</td>'; 
      $s .= '</tr>'; 
      $s .= '<tr>'; 
       $s .= '<td align="center" style="height:35px; padding:2px; vertical-align:bottom;">'.$appendLinkBegin.'<b>'.$company_name.'</b>'.$addSpace.'<br />'.$num2.' '.$resultText.$appendLinkEnd.'</td>'; 
      $s .= '</tr>'; 
     $s .= '</table>'; 
    $s .= '</td>'; 
    //end row if out of results or reached max num for row 
    if($result_incSmall == $endRowSmall){ 
     $s .= '</tr>'; 
     $result_incSmall = 0; 
    }else if(($i+1) == $num_qk){ 
     if($result_incSmall < $endRowSmall){ 
      for($e=0;$e<=($endRowSmall-$result_incSmall);++$e){ 
       $s .= '<td class="td_formTitle_noBorder" align="center" style="padding:0px; text-indent: 0;" width="165" height="115" valign="bottom"><!--space--></td>'; 
      } 
      $s .= '</tr>'; 
      $result_incSmall = 0; 
     } 
    } 
    //increment inc 
    ++$result_incSmall; 
    /*END SMALL*/ 
} 
//display table 
if($where == ''){ 
    $b = '<input type="hidden" name="numberRes" id="numberRes" value="No Results" />'; 
    $s = '<input type="hidden" name="numberRes" id="numberRes" value="No Results" />'; 
} 
echo '<table cellpadding="0" cellspacing="0" border="0" width="100%">'; 
    //results 
    echo '<div class="rowFillBig">big7Results'.$b.'</div>'; 
    echo '<div class="rowFillSmall" style="display:none;">small5Results'.$s.'</div>'; 
echo '</table>'; 

jQuery函數:

$(function() { 
    $('#tab_1').click(function(){ 
     $('#tab_vid').toggle(); 
     if ($("#mainContentRF").width() == 825){ 
      $("#mainContentRF").width(1180); 
      $("audio").width(800); 
      //if viewing the full screen pause video 
      <?php if($viewingVideo > ''){ ?> 
      video = $('.videoplayer').get(0); 
      video.pause(); 
      <?php } ?> 
      <!--hide small--> 
      $(".rowFillSmall").css("display", "none"); 
      <!--show big--> 
      $(".rowFillBig").css("display", "inline"); 
     }else{ 
      $("#mainContentRF").width(825); 
      $("audio").width(500); 
      <!--show small--> 
      $(".rowFillSmall").css("display", "inline"); 
      <!--hide big--> 
      $(".rowFillBig").css("display", "none"); 
     } 
    <!--if tab was left open dont close it--> 
    <?php if($acc_openValue_1 == '99'){ ?> 
     }) 
    <?php }else{ ?> 
     }).click(); 
    <?php } ?> 
}); 

如果我能得到更清晰,請讓我知道。基本上div和裏面的任何內容應該隱藏,當被問及時顯示。

+0

嘗試瞭解別人的PHP非常混亂。由於這聽起來像你的問題實際上是一個HTML和jQuery問題(並不真正與PHP有關),你能告訴我們正在生成的最終HTML嗎? – 2011-03-30 18:38:26

回答

0

把div放在桌子外面就好。

echo '<div class="rowFillBig">';  
    echo '<table cellpadding="0" cellspacing="0" border="0" width="100%">'; 
     //results 
     echo $b; 
    echo '</table>'; 
echo '</div>'; 
echo '<div class="rowFillSmall" style="display:none;">'; 
    echo '<table cellpadding="0" cellspacing="0" border="0" width="100%">'; 
     //results 
     echo $s; 
    echo '</table>'; 
echo '</div>';