jquery to calculate squarefoot
<p>I am working on following link:
<a href="http://www.marvelfloors.com/ProductDetails.asp?ProductCode=0_OH501" rel="nofollow">http://www.marvelfloors.com/ProductDetails.asp?ProductCode=0_OH501</a></p>

<p>I have implemented carton estimator on above page using jquery.But i want the calculations to be done as follows:
The minimum quantity to be ordered is 5 cartons.</p>

<p>If customer chooses less than 121.50 sqft or 5 cartons, e.g., 100 sqft, it will detect,
and it will change the number to 121.50 sqft, 5 cartons. If it’s more than 121.50 sqft,
it will calculate, e.g., customer enters 122, it change to 6 cartons.</p>

<p>For each legitimate sqft or carton value entered, you will need to check whether
they are over 800 sqft (the price break point), and change whether to show x $101.82
or x $96.96 accordingly, and price after the “= ”sign.</p>

<p>the following jquery i have used:</p>

<pre><code>// calculator sqft
    $(function() {
        // prepare calc
        $('.colors_pricebox').after().append('&lt;div id="calculator_sqft"&gt;&lt;div class="calculator_sqft_t"&gt;&lt;table border=0&gt;&lt;tr&gt;&lt;td colspan=4 class=titlecalc&gt;Cartons estimator&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td valign=top align=center class=sqfttt&gt;&lt;input type=text name=sqft value="" /&gt;&lt;br&gt;sqft&lt;/td&gt;&lt;td&gt;&lt;img src="http://www.rtaflooring.com/v/vspfiles/templates/adorn/images/sqft-cartons-arrow.png" style="margin-top: -12px;"&gt;&lt;/td&gt;&lt;td valign=top align=center class=cartonsttt&gt;&lt;input type=text name=cartons value="" /&gt;&lt;br&gt;cartons&lt;/td&gt;&lt;td valign=top class=xttt&gt;x&lt;/td&gt;&lt;td valign=top class=csqft_pricettt&gt;$&lt;span class=csqft_price&gt;&lt;/span&gt;&lt;/td&gt;&lt;td valign=top class=xttt&gt;=&lt;/td&gt;&lt;td valign=top class=result_csqft&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;/div&gt;');
        // end prepare calc

        $('#calculator_sqft .result_csqft').html('$0.00');
        var sqft = $('#calculator_sqft input[name=sqft]').val();
        $('#calculator_sqft input[name=sqft]').live('keyup', function() {
        if ($('#calculator_sqft input[name=sqft]').val() &gt; $('.test').html()) 
        {
            $('#calculator_sqft .csqft_price').html($('.sqft_cart_price').html());

            //var sqft = $(this).val();
            var sqft = $('#calculator_sqft input[name=sqft]').val();
            var sqft_cart = $('.sqft_cart').html();
            var csqft_price = $('.csqft_price').html();
            var result_cart = Math.floor(sqft / sqft_cart);
            var final_price = result_cart*csqft_price;

            $('input[name=cartons]').val(result_cart);
            $('.result_csqft').html('$' + final_price.toFixed(2) + ' &lt;span style="color: #f0b404; font: 14px arial;"&gt;&lt;/span&gt;');
            $('input').eq(2).val(result_cart);
        }
        else if ($('#calculator_sqft input[name=sqft]').val() &lt;= $('.test').html()) {
            $('#calculator_sqft .csqft_price').html($('.proprice').html());
            //var sqft = $(this).val();
            var sqft = $('#calculator_sqft input[name=sqft]').val();
            var sqft_cart = $('.sqft_cart').html();
            var proprice = $('.proprice').html();
            var result_cart = Math.floor(sqft / sqft_cart);
            var final_price = result_cart*proprice;

            $('input[name=cartons]').val(result_cart);
            $('.result_csqft').html('$' + final_price.toFixed(2) + ' &lt;span style="color: #f0b404; font: 14px arial;"&gt;&lt;/span&gt;');
            $('input').eq(2).val(result_cart);

        }
        });
    });
// end calculator
</code></pre>
