2016-11-12 248 views
1

我想在每次使用時更新我選擇的元素中的顯示數據editqtycan.php在一個彈出窗口中。我正在創建一個條碼系統。請幫助我如何在不刷新頁面的情況下更新它。自動刷新顯示錶無需重新加載頁面

<?php 

$sql="SELECT allinvty3.*, barcode.* , pd_stock_transfer.*, barcode.qty as codeqty, barcode.id as barcodeid from pd_stock_transfer 
      LEFT JOIN barcode on pd_stock_transfer.in_code = barcode.itemcode 

      INNER JOIN allinvty3 on pd_stock_transfer.in_code = allinvty3.in_code 
      where pd_stock_transfer.refnumber='$temp' and barcode.refnumber='$temp' and barcode.receivestatus='INCLUDED' group by barcode.itemcode ORDER BY allinvty3.ecr_desc ASC "; 
      $result = $conn->query($sql); 

echo"<div style='height:450px; overflow-y: scroll;'>"; 
echo "<table class='table table-bordered table-hover table-condensed '>"; 
      echo"<tr class='info'><th>MODEL</th><th>ITEM CODE</th><th>ACTUAL REC.</th><th>REQUEST QTY.</th><th>DIFF.</th> 
      </tr>"; 
      echo"<font size='5'><p class='text-primary'>ACTUAL</p></font>"; 

      while($row = $result->fetch_assoc()){ 
      $receivestatus =$row['receivestatus']; 
      $icount = $row['codeqty']; 
      $qty = $row['qty']; 
      $total1 = $row['codeqty'] - $qty; 

//I want this division an auto update every time I want to edit the ***qty row***. 
       echo"<tr>"; 
        echo "<td align= center>".$row['ecr_desc']."</td>"; 
        echo "<td align= center>".$row['itemcode']."</td>"; 
        echo "<td align=center>".$row['codeqty']."</td>"; 
        echo "<td align=center>".$row['qty']."</td>"; 
        if ($icount > $row['qty']){ 
        echo" 
        <td bgcolor='#FF0000' align='center'>";} 
        else if ($icount < $row['qty']){ 
        echo"<td bgcolor= '#006400' align='center'>"; 
        } 
        else{ 
        echo" 
        <td align='center'>"; 
        } 
        { 
        echo " ".$total1."</td>"; 
        } 
     //this link is where I can edit the qty in a popup window. I don't want to use bodyonunload.   
     echo"<td><a href='#' onclick=PopupCenter1('editqtyscan.php?Tid=".$row['barcodeid']."','myPop2',400,400)>Edit Qty</a></td>"; 
        }?> 
        </tr> 
</table></div></div> 

回答

0

是的。可以僅刷新頁面上的選定元素。您可以通過使用AJAX通信的JavaScript代碼來完成此操作。您可以使用jQuery庫,合理地利用它爲您的代碼很快做到這一點。閱讀jQuery的文檔$就功能:http://api.jquery.com/jquery.ajax/

或者,也許你並不需要與服務器的PHP腳本進行通信。也許你可以通過只在(瀏覽器)使用JS在客戶端達到你的目的。

而最後一件事。儘量避免混合使用HTML和PHP。我的意思是echo "<div></div>「'。您可以關閉PHP標籤並編寫乾淨的HTML代碼。它看起來更好,效率更高。

+0

謝謝你的建議,我會記住這一點。 – EHEM

相關問題