I'm trying to get a dynamic promotional code system to work. Basically, the AJAX is validating the promotional code by comparing what the customer typed with a MySQL database. The discount rate is currently set to 20%, but I'm trying to make it more dynamic. I added a field to the MySQL database called "discount" and now I want to reference that field in AJAX. Here is the code I am working with: if(responseText == "Valid") { cost = cost - (cost * 0.20) cost = parseInt((cost)*100)/100; document.getElementById('purchaseprice').value = cost; document.getElementById('pricediv').innerHTML = "$"+cost; divobj.style.color="##006600"; divobj.innerHTML=xmlHttp.responseText; } So basically, instead of: cost = cost - (cost * 0.20) I want cost = cost - (cost * discount) How do I define the discount variable in AJAX so it references that field in the MySQL table? Thanks guys!
I'm not quite sure if I follow, but why couldn't you replace the 0.20 with the variable that stores the discount amount from the database? Not sure what language you are using.