Page 1 of 1

Need help with Calculator code.

Posted: Thu Oct 27, 2011 2:46 pm
by ducklips
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:

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

	        }

Re: Need help with Calculator code.

Posted: Thu Oct 27, 2011 2:56 pm
by manohoo

Code: Select all

var prodRect = 1.05 * length * width / 500

Re: Need help with Calculator code.

Posted: Fri Oct 28, 2011 10:27 am
by ducklips
Thank you so much!

:)