Mulch Calculator using jQuery

Mulch CalculatorI’ve been toying around with learning jQuery, lately. I went out and bought a book and started going through the exercises. jQuery is really a sub library of JavaScript and it’s a really popular way to add cool enhancements to a website.

According to Wikipedia:

jQuery is a cross-browser JavaScript library designed to simplify the client-side scripting of HTML. It was released in January 2006 at BarCamp NYC by John Resig. Used by over 31% of the 10,000 most visited websites, jQuery is the most popular JavaScript library in use today.
http://en.wikipedia.org/wiki/JQuery

As with any language on the web (and spoken languages, too), you can do some cool stuff even without being completely fluent in it. Thought I haven’t been using jQuery very long, I’ve already completed two projects with it.

My latest project was to build a mulch calculator that would help the user to know how many yards of mulch they will need to fill a certain spot. The user needs to know 3 things:

  1. Length in Feet
  2. Width in Feet
  3. Thickness in Inches

Here’s the formula for calculating what you need:
(Length * Width * (Thickness / 12)) / 27

You’ll notice that there is a semi-complex order of operations going on here

  • First we have to convert the inches to be on the same playing field as the feet by dividing by 12.
  • Then we have multiply length, width and our converted thickness together.
  • And lastly, all of that is divided by 27.

After much trial error, here is the JSFiddle.

The actual calculator can be found here: www.adamslandscapingandsupply.com/calculators

Leave a Reply