Need help with Calculator code.
Posted: Thu Oct 27, 2011 2:46 pm
I would appreciate any help you can offer. I am creating a calculator code on a website used to determine how many pallets of sod are needed based on square feet.
One pallet is 500 sq ft, so the total amount needs to be divided by 500. The 5% is the loss percentage, so if someone has 10,000 sq feet, they would need 21 pallets rather than the 20 without the 5%.
The formula is rather basic, and is as follows:
(example)
width x height + 5% / 500
I have it working until I try adding the 5% part, and I tried using 0.05 instead, but no luck.
Below is the code without the percentage, I tried a bunch of scenarios with the percentage, but as I mentioned, no luck.
Thanks in advance:
One pallet is 500 sq ft, so the total amount needs to be divided by 500. The 5% is the loss percentage, so if someone has 10,000 sq feet, they would need 21 pallets rather than the 20 without the 5%.
The formula is rather basic, and is as follows:
(example)
width x height + 5% / 500
I have it working until I try adding the 5% part, and I tried using 0.05 instead, but no luck.
Below is the code without the percentage, I tried a bunch of scenarios with the percentage, but as I mentioned, no luck.
Thanks in advance:
Code: Select all
function calcRect() {
if(validNumber(document.getElementById('length'), 'length') == true) {
if(validNumber(document.getElementById('width'), 'width') == true) {
var length = (document.getElementById('length').value)
var width = (document.getElementById('width').value)
var prodRect = length * width / 500
document.getElementById('ansRect').value = prodRect
}