Discussion Locked

Math calculations in forms

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
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?

3 replies

by dan cooperstock

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 control (assuming that's what you meant when you said they selected a quantity - a drop-down). If it's just a regular 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

by rjclawson

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)

This discussion is closed to new replies.