OK, I made a couple of changes. First, I changed the form where it is setting up the field to this, because I wanted it to check the coupon code when it loses focus:
Code:
<input type="text" class="inputbox" name="coupon_code" onblur="checkCode(this)" value="<?php echo $this->couponCode; ?>" size="18" />
then I changed the function that I created to:
Code:
function checkCode(couponCode, coupon)
{
var code = couponCode.value
var $coupon = ""
if(code == '6') {
$coupon = "you have entered 6";
return $coupon;
} else if(code == "BrewClub") {
alert("30% off will be applied at checkout if valid");
} else if(code == "WineClub") {
alert("40% off will be applied at checkout if valid");
} else if(code == "YP Brew Club") {
alert("30% off will be applied at checkout if valid");
} else if(code == "GF YP Brew Tour") {
alert("52% off will be applied at checkout if valid");
} else if(code == "GF YP Wine Tour") {
alert("48% off will be applied at checkout if valid");
} else {
}
}
What I would like it to do at this point, and I would appreciate any help, is to pull in the coupon codes in the database into an array, along with the discount percentage, then check the coupon code against that array and return the discount percentage to be displayed in an alert box (as is accomplished above). Otherwise, everytime I enter an new code, I would have to come back and edit the form and function.