0

我需要对一个网站进行修改,迫使我在不刷新其内容的情况下更新页面中的数据。系统应该改变,因此当访问者输入零件编号时,会显示单个单元的价格以及数量折扣。当访问者选择赋予访问者折扣的数量时,将显示新价格以及相应的折扣范围。我们的系统现在运行良好,但它包括几个阶段,不会让用户在初始搜索阶段选择数量。我需要使用 jquery 连接到数据库并为所选数量获取正确的价格和折扣范围。这是需要更改的代码。

 <body >


<table  border="0" cellspacing="0" cellpadding="0" align="center">
<tr> 
<td  align="center">

 <?php
 include ("../includes/java_update.php");
?>
<table   width="100%" >

                        <?php
    while ($row = mysql_fetch_array($result))
    {
        // Increment the total cost of all items
        ?>
<tr class="inside1">
                          <td colspan="8"><hr size="1" >                                </td>
                        <tr id="inside">
                             <td><input  type="text" name="<?php echo $row["part_number"];?>"    value="<?php echo $row["qty"];?>" id="t"  onBlur="UpdateQty2(this.name,this.value)"  size="3" >                              </td>
                          <td><input name="button" type="button"value="Update" class="button"></td>
                              <td class="disc" width="12%" height="25"><?php echo    $row["part_number"]; ?> </td>
                              <td class="discleft" width="39%" height="25">
 <?php 



                            echo $row["disc"]; ?>                              </td>
                          <td id="price" width="6%" height="25">&pound;
                              <?php 

                            for($in =1 ; $in <= 8; $in++)
                            {
                            $bb=$row["price_break".($in)];

                            $halves =explode("-",$bb);
                            $firstnumber=$halves[0];
                            $secondnumber=$halves[1];




                        If ($row["qty"] >= $firstnumber && $row["qty"] <= $secondnumber)

                        {
                        echo number_format($row[("price_each".$in)], 2, ".", ",");


                    tprice ($row["part_number"],$row[("price_each".$in)],$row[("qty")]);
                    //echo"part_number is ".$row["part_number"];
                    //echo "<br>";
                    //echo"price_each is ".$row[("price_each".$in)];


                        $which=$in;

                        $totalCost += ($row["qty"] * $row[("price_each".$which)] );
                        }


                            }



                                ?>                            </td>
                           <td align="center"  class="in_stock">

                          </td>
                          <td width="9%" height="25" class="pblist" ><select name="pb" >
                              <?php


                        $c=$row["price_each1"];//  price for single item


                            for($i = 1; $i <= 8; $i++)
                            {


                            $b=$row["price_each".$i];


                            if ($b !=0.00)
                                {

                                $d=(($c-$b)/$c)*100;



                            $complete=$row[("price_break".$i)]. " ," .round($d)."%";    
                    echo "<option ";


                            if ($i == $which)
                                    {
                                        echo " SELECTED ";
                                    }
                            echo ">". $complete ."</option>";       



                            }
                            }


                            ?>
                          </select>                              </td>
                          <td id="removeit"><a id="removeit" href="cart_wp.php?    action=remove_item&id=<?php echo $row["part_number"]; ?>">Remove</a> </td>
                        </tr>

<script type="text/javascript">

function UpdateQty2(s,m)
            {
        var part_number=s;




        if (isNaN (m)) {
    // Not A Number
   alert('Please enter a valid no.') ;
 } else {


        var newQty=m;


        document.location.href = 'cart_wp.php?action=update_item&id='+part_number+'&qty='+newQty;
        }


    }

4

1 回答 1

2

$.post()文档

$.ajax({
  type: "POST",
  url: url,
  data: data,
  success: success,
  dataType: dataType
});
于 2013-08-20T09:09:04.173 回答