0

我在这里开发了一个交易功能。但是我在使用 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>
4

1 回答 1

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
    
    })
    

如果你能做到以上 - - 一切都会好起来的

于 2013-01-25T19:42:47.677 回答