Need help with Calculator code.

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
ducklips
Forum Newbie
Posts: 2
Joined: Thu Oct 27, 2011 2:38 pm

Need help with Calculator code.

Post 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

	        }
User avatar
manohoo
Forum Contributor
Posts: 201
Joined: Wed Dec 23, 2009 12:28 pm

Re: Need help with Calculator code.

Post by manohoo »

Code: Select all

var prodRect = 1.05 * length * width / 500
ducklips
Forum Newbie
Posts: 2
Joined: Thu Oct 27, 2011 2:38 pm

Re: Need help with Calculator code.

Post by ducklips »

Thank you so much!

:)
Post Reply