传递两个表之间的值

时间:2013-01-25 19:33:26

标签: php javascript

我在这里开发了一个交易功能。但我在使用javascript时遇到了麻烦。如下所示,有两个表,第一个用于显示项目,第二个表用于购买。我想要做的是,第一个表中项目的行是可点击的。单击该行时,已选择的项目将在第二个表中显示。在第二个表格中,折扣可以编辑,总价格也可以通过折扣来改变。任何人都可以帮我传递这两个表之间的值吗?

<fieldset>
<legend>Item Show</legend>
<table border="1">
<tr>
  <td>Item Name</td>
    <td>Item Code</td>
    <td>Manufacturer</td>
    <td>Price</td>
    <td>Stock</td>
</tr>
<?php
while($row = mysql_fetch_array($result))
  {
?>
<tr>
  <td><?php echo $row['item_name']; ?></td>
    <td><?php echo $row['item_code']; ?></td>
    <td><?php echo $row['item_manufacturer']; ?></td>
    <td><?php echo $row['sell_price']; ?></td>
    <td><?php echo $row['stock']; ?></td>
</tr>
<?php
}
?>
</table>
</fieldset>

<fieldset>
<legend>Item Sale</legend>
<table border="1">
<tr>
  <td>Item name</td>
    <td>Item Code</td>
    <td>Stock</td>
    <td>Price</td>
    <td>Quantity</td>
    <td>Discount</td>
    <td>Total Price</td>
</tr>
</table>
</fieldset>

1 个答案:

答案 0 :(得分:0)

以下是您应遵循的步骤。

  1. 为所有喜欢的人提供一个共同的课程
  2. 使用像

    这样的jQuery事件
      $(".clickable").on('click',function(e,this){
        //a.use "this" here to extract values that you want to pass to other table
        //b.append <tr><td></td>....</tr> with this.values to your table
    
    })
    
  3. 如果你能做到以上几点 - 事情就会好起来

相关问题