View Full Version : Price calculator and rounding

10-05-2011, 04:08 PM
I am currently using a price calculator - although it's really not a calculator; I have to enter every price manually. Currently, it works in half inch increments.

I need it to do two things that it doesn't do currently:
1) Allow the customer to enter a dimension in 1/4 inch increments (1/8 would be even better, but I'm not requesting a miracle)
2) Make the result automatically round up to the nearest 1/2 inch

Page containing calculator (http://www.stadriemblems.com/auto-quote.html)

External file: sizecalc.js (http://www.stadriemblems.com/sizecalc.js)

Old Pedant
10-05-2011, 08:24 PM
How do you want them to *enter* the fractions?

Do you want them to be 3 3/8 (depending on a space between the whole number and the fraction) or do you want to make the user enter 3.375?

Clearly, making the user enter the size as a decimal fraction makes the whole exercise trivial. It's only the need to translate mixed fractions to decimal, do the calculations (?? which are what??) and then convert the decimal back to mixed fraction that's a lot of work.

Old Pedant
10-05-2011, 08:27 PM
I don't understand this calculation:

size = (parseFloat($('patch_width').value) + parseFloat($('patch_length').value)) / 2;

That's clearly not trying to calculate the *AREA* of the patch. Is it just some kind of arbitrary measurement used in your system?