Is it possible to pass variables into a js function? See 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 <= StartingPrice) && (StartingPrice > 0)){
alert("The 'Buy It Now' price must be higher...");
return false;
}
if((Reserve <= StartingPrice) && (StartingPrice > 0)){
alert("Your 'Reserve Price' must be higher...");
return false;
}
return true;
}
}
I'd like to take the var BuyItNowPrice = parseFloat($('#BuyItNowPrice').val()); etc and place them outside the function, then call them in.
The reason is I have 3 of these functions so these 3 variables (BuyItNowPrice, StartingPrice, Reserve) are repeated 9 times, 3 in each function.
Is there a way of doing this?
Any help would be Greatly Appreciated, Thanks