jknj72
asked on
Calculate fields in aspx
I have a form where the user sets a few decimal fields and if the user tabs through the fields the 'total' field calculates all the fields together and gets set and everything works fine but if they use their mouse this is where my troubles begin. I know it is because of the keyup in my function but I wanted to know if there is something else that I can use like something similar to onblur() maybe? I am new to javascript and jquery so I have no clue so any advice would be great.
Here is my code...
Thanks for the help!!!
Here is my code...
<%--Being used for generating Travel item cost values for the Total--%>
<script type="text/javascript">
$(document).ready(function () {
$(".toCalculate").keyup(function () {
var total = 0;
$(".toCalculate").each(function (index, item) {
temp = parseFloat($(item).val());
if (isNaN(temp))
temp = 0;
total = total + temp;
});
$(".total").val(total.toFixed(2));
});
});
</script>
Thanks for the help!!!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
neither was the best solution but it made me choose one so I chose the first one. Again, thanks for your help
ASKER