General discussion

Locked

Math calculations in forms

By breakthr ·
A form I am currently designing requires the user to enter the quantity of units required. When the user has made a selection I wish the quantities to be multiplied by the prices per unit and the VAT added to give a total in Euros. I have designed the form however don't know how to add the math functionality, anyone know how to help?

This conversation is currently closed to new comments.

3 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

There is a tool for that: ExcelEverywhere

by MattiasW In reply to Math calculations in form ...

Define the calculations by creating a spreadsheet that does it. ExcelEverywhere will create a web page where JavaScript is used for the calculations, so Excel is only needed when creating the webpage. The users doesn't need Excel. For a sample see

http://www.xleverywhere.com/samples/order_form/order_form1.htm

Just enter values into the Qty-column and press tab and the values are updated immediately.

More info at http://www.exceleverywhere.com

Regards,

Mattias

Collapse -

Calculations in web forms

by Dan Cooperstock In reply to There is a tool for that: ...

I presume you are talking about a form on an HTML page, since you didn't say.

Basically you need to use some JavaScript. You need to script the OnChange event of your <SELECT> control (assuming that's what you meant when you said they selected a quantity - a drop-down). If it's just a regular <INPUT TYPE=TEXT> control, there's a different event (I think OnChange).

HOWEVER, you really have to keep in mind that some users will have JavaScript turned off. So, although you can offer immediate feedback for some users, you either have to prevent users with JavaScript turned off from using the page (via a <NOSCRIPT> section) or you have to do the same calculations server-side.

Collapse -

Windows

by RJClawson In reply to Math calculations in form ...

Try this, you do not need any special references.

Total = bQuantity.text * EurosPerUnit + VAT


If the VAT is a percent of the Total try

Total = (bQuantity.text * EurosPerUnit) * (1 + VatRate)

Back to Web Development Forum
3 total posts (Page 1 of 1)  

Related Discussions

Related Forums