We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

How can I calculate the sum of a few form fields filled out by a visitor?

Development and Programming

bgarrant's avatar
bgarrant
356 posts
14 years ago
bgarrant's avatar bgarrant

I have a form on my website with a few fields that a user will fill out. Basically I need to add some user input values, subtract some user input value, multiply by a fixed value and get a total. What is best way to calculate on the form? Should I use an extension like MX Calc with onBlur field events? Can i use MX Calc even with a form? Any other jquery method? I am open to suggestion. Thanks.

       
bgarrant's avatar
bgarrant
356 posts
14 years ago
bgarrant's avatar bgarrant

I was also looking at Math Plus and Simple Math add-ons. Is there a better way to calculate a value in a user input form within EE? Here is the formula I am trying to use for a gas savings calculation:

___ Enter the number of gallons of oil you used in the last 12 months. ___ Enter the price per gallon of oil. Multiply Line 1 x Line 2. Multiply Line 1 x 1.39 to get the equivalent therms of natural gas. 1.41 Enter the current price per therm ($1.41) Multiply Line 4 x Line 5 Subtract Line 6 from Line 3 to find your annual savings using natural gas.

___ Results

       
the3mus1can's avatar
the3mus1can
426 posts
14 years ago
the3mus1can's avatar the3mus1can

This could all be done with Javascript.

       
icebreaker's avatar
icebreaker
50 posts
14 years ago
icebreaker's avatar icebreaker

You could perhaps take a look at JQuery calc plugin

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.