【问题标题】:jQuery/Grails- Detect Row in a Table when textbox is changingjQuery/Grails - 当文本框改变时检测表中的行
【发布时间】:2015-10-05 16:35:37
【问题描述】:

更改字段 B 后,我需要重新计算字段 A。

但它们在一个有“n”行数的表中排成一行(foreach)。

为了进行必要的重新计算,我必须获取进行更改的行。这是一个示例代码。谢谢!

 $('#number').keyup(function () {
        
               var num=parseFloat($('#number').val());
               var price=parseFloat($('#price').val());
              
               var newAmount= num*price;
               
               document.getElementById("priceAmount").value = newAmount;
               
});
<table>
  <thead>
  <tr>
    <th> Name <th>
    <th> Product <th>
    <th> Price <th>
    <th> Number <th>
    <th> Price Amount <th>
  <tr>
  </thead>
  <tbody>
    <tr>
     <g:each var="sale" status="i" in="${saleInstanceList}">
       <td>${sale.name}"></td>
       <td>${sale.product}"></td>
       <td>${sale.price}"></td>
       <g:hiddenField name="price" value="${sale.price}"/>
       <td><g:textField name="number" value="${sale.number}"></g:textField></td>
       <td><g:textField name="priceAmount" value="${sale.priceAmount}"></g:textField></td>
     </tr>
     </g:each>
  </tbody>
</table>
  

【问题讨论】:

    标签: javascript jquery html grails


    【解决方案1】:

    我猜你必须为每行创建一个 jquery 函数并使用 row-id 等创建变量...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-01-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-02-20
      • 1970-01-01
      • 2011-10-04
      相关资源
      最近更新 更多