How do I pass variables into a JavaScript function?
<p>Is it possible to pass variables into a js function? See code:</p>

<pre><code>function checkStartPrice (){
    if ($('#StartingPrice')[0].value.length == 0){
        alert("The 'Starting Price' cannot be left empty!");
        return false;
     } else {
        var BuyItNowPrice = parseFloat($('#BuyItNowPrice').val());
        var StartingPrice = parseFloat($('#StartingPrice').val());
        var Reserve = parseFloat($('#Reserve').val());
        if((BuyItNowPrice &lt;= StartingPrice) &amp;&amp; (StartingPrice &gt; 0)){
            alert("The 'Buy It Now' price must be higher...");
            return false;
        }
        if((Reserve &lt;= StartingPrice) &amp;&amp; (StartingPrice &gt; 0)){
            alert("Your 'Reserve Price' must be higher...");
            return false;
        }
        return true;
    }
}
</code></pre>

<p>I'd like to take the <code>var BuyItNowPrice = parseFloat($('#BuyItNowPrice').val());</code> etc and place them outside the function, then call them in. </p>

<p>The reason is I have 3 of these functions so these 3 variables (<code>BuyItNowPrice</code>, <code>StartingPrice</code>, <code>Reserve</code>) are repeated 9 times, 3 in each function.</p>

<p>Is there a way of doing this?</p>

<p>Any help would be Greatly Appreciated, Thanks</p>
