Calculating shipping & handling - JavaScript
<p>I'm trying to accomplish the following problem:</p>

<blockquote>
  <p>Many companies normally charge a shipping and handling charge for purchases. Create a Web page that allows a user to enter a purchase price into a text box and includes a JavaScript function that calculates shipping and handling. Add functionality to the script that adds a minimum shipping and handling charge of $1.50 for any purchase that is less than or equal to $25.00. For any orders over $25.00, add 10% to the total purchase price for shipping and handling, but do not include the $1.50 minimum shipping and handling charge. The formula for calculating a percentage is price * percent / 100. For example, the formula for calculating 10% of a $50.00 purchase price is 50 * 10 / 100, which results in a shipping and handling charge of $5.00. After you determine the total cost of the order (purchase plus shipping and handling), display it in an alert dialog box.</p>
</blockquote>

<p>Here's my code so far:</p>

<pre><code>&lt;script type="text/javascript"&gt;
/*&lt;![CDATA [*/

//Shipping &amp; handling fee
    var price = 0;
    var shipping = 0;
    var total = price + shipping;
    function calculateShipping(price){
    //Add $1.50 with any purchase that is less than or equal to $25.00
    if (price &lt;= 25){
     return 1.5;
    }
    //Add 10% with any purchase that is greater than $25.00 but do not inlcude the $1.50 fee
    else{
     return price * 10 / 100
    }
    }


/* ]]&gt; */
</code></pre>

<p>.. and my HTML</p>

<pre><code>&lt;form&gt;
    &lt;table&gt;
    &lt;p&gt;
    &lt;tr&gt;
        &lt;td&gt;Enter purchase price&lt;/td&gt;
        &lt;td&gt;&lt;input type="text" name="inputPrice" size="6" onchange="" /&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Shipping &amp;amp; handling&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td/&gt;
        &lt;td&gt;&lt;input type="button" name="calcShipping" value="Calculate" onchange="" /&gt;&lt;/td&gt;
    &lt;/p&gt;
    &lt;/table&gt;
&lt;/form&gt;
</code></pre>

<p>I wanna go the extra mile and I'd like to show the shipping &amp; handling fee prior to clicking the Calculate button, in other words, as soon as I type the purchase price, the S&amp;H price appears and then, when clicking the button, the alert dialog box show my total price.</p>

<p>P.S. I still have problems with how to call functions :S</p>
