jquery - result not getting in to the field -
here have 3 fields , while adding values in 2 fields sum of value should enter in third field here sum function not getting here code
<script type="text/javascript"> $(document).ready(function () { var balanceamount = $("#balance").val(); var actual_amount = $("#total_amount").val(); var total_balance = $("#totalbalance").val(); $("#amount").keyup(function () { var amount = $("#amount").val(); var total_balance = $("#totalbalance").val(); var total_amount = total_balance + amount; alert(total_amount); $("#total_amount").val(total_amount.tofixed(2)); }); }); </script>
you need parsefloat()
values...
<script type="text/javascript"> $(document).ready(function () { var balanceamount = parsefloat( $("#balance").val() ); var actual_amount = parsefloat( $("#total_amount").val() ); var total_balance = parsefloat( $("#totalbalance").val() ); $("#amount").keyup(function () { var amount = parsefloat( $("#amount").val() ); var total_balance = parsefloat( $("#totalbalance").val() ); var total_amount = total_balance + amount; alert(total_amount); $("#total_amount").val(total_amount.tofixed(2)); }); }); </script>
Comments
Post a Comment