I’m trying to create a simple coupon code area for my website. I thought I’d be able to figure it out, but I’m having some trouble. Essentially, I need a code that will take a text input and pump it out as a correlating numerical output. For example: bigdiscount = -50. I’m getting the output with my current code, but the problem is “-50” shows up no matter what I type in as input. The “else” statement seems to have no effect. I feel like I must be close, but I’m missing something…or maybe I’m trying to do this too simply. Any ideas? Thanks in advance!
Here’s my code right now:
(In head?
function searchForModifier(){
var modiferCode = document.getElementById(“modifierCodeText”).value;
var discount
if (modifierCode = “bigdiscount”) {
discount = -50;
}
else{
discount = 0;
}
document.getElementById(“priceModify”).value = discount;
return;
}
(In body?
<input type=”text” id=”modifierCodeText” size=”15″ onkeydown=”document.getElementById(‘priceModify’).value=””>
<br />
<input type=”button” onclick=”searchForModifier()” value=”Click here to find your price modifier”>
Price Modifier:
$<input name=”pricemodifier” type=”text” id=”priceModify” size=”5″ readonly>