如何在jquery中的同一输入字段上多次使用onkeyup事件?

时间:2018-05-02 10:58:28

标签: jquery onkeyup

我正在制作我希望进行一些计算的表格。我正在使用jquery.Below是html代码和jquery函数。

function sum(param,id) 
        {
            var daysWork = document.getElementById('days_work_'+id).value;
            var rateReceived = document.getElementById('rateReceived_'+id).value;
            var percPaid = document.getElementById('perc_paid_'+id).value;
            var paidFrmUk = document.getElementById('paidFrmUk_'+id).value;
            var paidFrmIndia =  document.getElementById('paid_from_india_'+id).value;
            var remaining =  document.getElementById('remaining_'+id).value;


            var totalDisplay = rateReceived * daysWork;
            var total = totalDisplay.toFixed(2);
            document.getElementById('total_'+id).value = total;   

            var toBePaidDisplay = (totalDisplay * percPaid)/100;
            var toBePaid = toBePaidDisplay.toFixed(2);
            document.getElementById('tobe_paid_'+id).value = toBePaid;

            var paidFrmIndiaDisplay = toBePaid - paidFrmUk;
            var paidFrmIndia = paidFrmIndiaDisplay.toFixed(2);
            var paidFrmIndia = document.getElementById('paid_from_india_'+id).value = paidFrmIndia;

            var addUkIndiaSal = Number(paidFrmIndia) + Number(paidFrmUk);
            var remainingDisplay = toBePaid - addUkIndiaSal;    
            var remaining = remainingDisplay.toFixed(2);
            document.getElementById('remaining_'+id).value = remaining;

        }



<td><?php echo $RATE_RECEIVED;?></td>
<td><?php echo $CURRENCY_CODE;?></td>   
<td><?php echo $PERC_PAID;?></td>    
<td><input type="text" onkeyup="sum(this,<?php echo $srNo;?>)"   id="days_work_<?php echo $srNo;?>"  value="<?php echo $DAYS_WORKED;?>" /></td> 
<td><input type="text"  id="total_<?php echo $srNo;?>"  value="<?php echo $TOTAL;?>"  /></td> 
    <td align="center"><input type="text"    id="tobe_paid_<?php echo $srNo;?>"  value="<?php echo $PER_TO_BE_PAID; ?>"  /></td> 
<td><input type="text" onkeyup="sum(this,<?php echo $srNo;?>)"  id="paidFrmUk_<?php echo $srNo;?>"  value="<?php echo$SAL_PAY_FRM_UK;?>" /></td>            
<td><input type="text" onkeyup="sum(this,<?php echo $srNo;?>)"  id="paid_from_india_<?php echo $srNo;?>"  value="<?php echo $SAL_PAY_FRM_INDIA;?>"  /></td> 
<td><input type="text" onkeyup="sum(this,<?php echo $srNo;?>)"   id="remaining_<?php echo $srNo;?>"  value="<?php echo$REMAINING;?>"  /></td>

根据我的功能,我的代码工作正常。但我还有一些其他条件,我无法用这段代码完成。

正如您可以在td paidFrmUk_,paid_from_india_,remaining_中看到最后3个输入。 我的计算方法类似于 paidFrmIndia = = toBePaid - paidFrmUk;

  

它的工作。但如果我想在计算后编辑paidFrmUk呢   不允许我编辑那个输入框。这是什么解决方案。   编辑按功能计算的输入框。

0 个答案:

没有答案