Pritaeas has a good sample but here are a couple of sources that may help you in triggering a clue: http://www.dzone.com/snippets/calculating-sum-2-form-fields
https://forums.digitalpoint.com/threads/dynamically-calculate-the-sum-of-fields.243388/
http://www.sitepoint.com/forums/showthread.php?461850-Calculate-sum-from-user-input-form-fields
http://www.webdeveloper.com/forum/showthread.php?138245-dynamically-calculate-the-sum-of-fields