I built this budget calculator using HTML, CSS & Javascript / JQuery a while back, and am wondering if someone here might be able to help me fix my javascript so that it's more efficient with adding up and calculating dollar amounts.
http://budget.egoselfaxis.com/
I'm a subcontractor, and I use this app to help keep track of my tax-adjusted income vs. expenses. Once you establish an "economic forecast" by filling in the 4 initial text input fields, you're able to add up individual expenses, .. drag and drop them to new positions (if necessary), .. and then delete each expense once it's been paid off. The result is a "tape roll" like summary of where you're at financially (meaning an estimate of how much extra spending money you should have left over if everything works out as planned).
Anyways, -- my javascript-based math functions are buggy, and sometimes result in obviously wrong and enormous amounts. I think part of the problem is that I'm purposefully excluding the penny values from some of my calculations, and have to accommodate for them programmatically as needed. Obviously I'm doing this incorrectly. What I'd like to do is have someone here help me fix it. Anyone care to lend a hand?
Feel free to bookmark this link if you find it useful in any way, by the way. You'll see that it uses HTML5's local storage functions, and doesn't require any server-side scripting. In fact -- you can just save it down to your local machine and to run it from there if you prefer.
Thanks, -- and happy new year!
- Yvan
2) change
$('.budget_item').each(fun
total = total + parseInt($(this).text());
});
to
$('.budget_item').each(fun
var val = $(this).text();
if (!val || isNaN(val)) val =0;
else val = parseInt(val,10);
total += val;
});
Can you give a step by step to recreate an error?