2015-10-05 30 views
0

我需要改變的場B.的jQuery/Grails-在一個表中檢測行當文本框被改變

後重新計算的場A,但它們是在一排IA表的「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> 
 

回答

0

我想你必須讓每行jQuery的功能,並創建行ID等變量...

相關問題