I have a form similar to this:
Code HTML4Strict:<form id="test"> <input type="text" class="amount" value="300"> <input type="text" class="amount" value="100"> <input type="submit" name="submit" value="Show Total"> </form>
... and the following jQuery to calculate the input values total:
Code JavaScript:var total = 0; $('#test').submit(function(e){ e.preventDefault(); $('.amount').each(function(index){ total += $(this).val(); }); alert(total); });
The problem is that,upon submit, I do not get a calculated total of all values. Instead, it just echo's out all the individual values.
What am I doing wrong here?



Reply With Quote


Bookmarks