2011-12-15 38 views
0

我有一個用於捕獲銷售訂單的php頁面。它有一個依賴的下拉列表,它根據選定的值提取mysql表信息。當依賴下拉列表刷新頁面時,將輸入框值存儲爲頁面

當用戶輸入的訂單數量,我想幾件事情發生:

  • 首先,輸入的數值應被寫入到變量$ line1qty。我有條目: <? $line1qty=$_POST[line1qty]; ?>在我的代碼但是這不工作,因爲我不知道它是在JavaScript刷新頁面時設置的。

  • 其次,下一個表格行應該是可見的,最多會有72個表格條目,我希望所有沒有選定值的行默認隱藏。

任何援助將不勝感激,我知道我只是缺少一些簡單的東西,但我還是很新的PHP。再次感謝。

我對頁面代碼是:

<style type="text/css"> 
<!-- 
@import url("style.css"); 
--> 
</style> 

<script language="JavaScript"> 

function autoSubmit() 
{ 
    var formObject = document.forms['theForm']; 
    formObject.submit(); 
} 

</script> 

<?php 

$packcode = $category = $sellingunit = null; //declare vars 

if(isset($_GET["packcode"]) && is_numeric($_GET["packcode"])) 
{ 
    $packcode = $_GET["packcode"]; 
} 

if(isset($_GET["category"]) && is_numeric($_GET["category"])) 
{ 
    $category = $_GET["category"]; 
} 

if(isset($_GET["sellingunit"]) && is_numeric($_GET["sellingunit"])) 
{ 
    $sellingunit = $_GET["sellingunit"]; 
} 

?> 

<form name="theForm" method="get"> 

<? $line1qty=$_POST[line1qty]; ?> 


Capture the sales data 
<table id="hor-minimalist-a"> 
    <tr> 
     <th valign=bottom> 
     Select a Pack Code 
     </th> 
     <th valign=bottom> 
     Category 
     </th> 
     <th valign=bottom> 
     Selling <br> Units 
     </th> 
     <th valign=bottom> 
     <b>Grouping</b> 
     </th> 
     <th valign=bottom> 
     <b>Full Pallet<br>QTY</b> 
     </th> 
     <th valign=bottom> 
     <font color=red><b>Order QTY</b></font> 
     </th> 
     <th valign=bottom> 
     <font color=green><b>Points</b></font> 
     </th> 

    </tr> 
    <tr> 
     <td> 
    <select name="packcode" onChange="autoSubmit();"> 
     <option value="null"></option> 
<option value="1046" <?php if($packcode == 1046) echo " selected"; ?>>1046 - Domestos Liq Lemon 20x750ml</option> 
<option value="1174" <?php if($packcode == 1174) echo " selected"; ?>>1174 - Omo Wash Pwdr MultiActiv6x6x500g</option> 
<option value="1175" <?php if($packcode == 1175) echo " selected"; ?>>1175 - Surf Wash Pwdr Reg 6x6x500g</option> 
<option value="1182" <?php if($packcode == 1182) echo " selected"; ?>>1182 - Breeze Soap Amber 8x12x125g</option> 


    </select> 
     </td> 
     <td width=75> 
      <?php 

    if($packcode != null && is_numeric($packcode)) 
    { 

     //POPULATE category 

     $sql = "SELECT packcode, sellingunits, category,casesperpallet,grouping,shrinksperpallet FROM skudata WHERE packcode = $packcode"; 
     $data = mysql_query($sql); 

     while($row = mysql_fetch_array($data)) 
     {   
      echo $row[category]; 

     ?> 
     </td> 
     <td width=75> 
     <? echo $row[sellingunits]; ?> 
     </td> 
     <td width=75> 
     <? echo $row[grouping]; ?> 
     </td> 
     <td width=75> 
     <? if($row[sellingunits]=="CS"){echo $row[casesperpallet];} else {echo $row[shrinksperpallet];} ?> 
     </td> 
     <td width=75> 
     <? if($line1qty > 0){ ?> 
     <input type=text name=line1qty id=line1qty size=3 value=<? echo $line1qty; ?> style=" color: red;text-align: center" onChange="autoSubmit();> 
     <? } else { ?> 
     <input type=text name=line1qty id=line1qty size=3 style="color: red;text-align: center"> 
     <? } ?> 
     </td> 
     <td width=75> 
     <input type=text name=line1points id=line1points size=3 disabled> 
     </td> 

    </tr> 

     <? 
      }} 
     ?> 

再次感謝,欣賞這個論壇提供了援助。

有一個好的一天, 瑞安

+1

你可以使用`AJAX`調用而不使用`POST`來更新數據,但問題仍然不清楚。你想幹什麼? – Sudantha 2011-12-15 07:49:12

回答

1

在這些線路:

<form name="theForm" method="get"> 
<? $line1qty=$_POST[line1qty]; ?> 

您可以使用 「$ _ POST」 但你的形式方法是$ _GET,所以使用$_GET["line1qty"]