Click here to Skip to main content
15,914,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
var amount = $("#txtAmnt").val();
$("#txtGrossAmnt").val(amount);
when value of txtAmnt changed to another value how can we produce new txtGrossAmnt as the sum of old txtGrossAmnt value and new txtGrossAmnt value
Posted

1 solution

HTML
<div>
       <input id="txtAmnt" type="text" />
       <input id ="txtGrossAmnt" type="text" />

   </div>




JavaScript
$("#txtAmnt").focusout(function ()
     {
         var amount = $("#txtAmnt").val();
         var grossAmount = $("#txtGrossAmnt").val();
         alert(grossAmount);
         if (grossAmount == '')
         {
             grossAmount = 0.0;
         }
         $("#txtGrossAmnt").val(parseFloat(grossAmount) + parseFloat(amount));
     })
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900