I need to write a jQuery / Java function that will take the numbers from an AJAX updated value, sanitize it to remove the $, reduce the price by a certain percentage (discPerc) and then make an alert window that notifies the customer of the reduced price.
Here’s what I have so far, I realize I’m not the best coder!
<head>
<script type="text/javascript">
function superSalePrice(discPerc) {
var optionPrice = $("#productTotal").val();
var applyDisc = optionPrice * discPerc;
var rPrice = Math.round(applyDisc * 1) / 1;
$("tB").click(function() {
alert("With selected options, final price with discounts is $" + rPrice + "!");
};
)
};
</script>
</head>
//THEN the button
<input type="button" id="tB" value="Test Disc. Calc." onclick="superSalePrice(.85);" />
//THEN the option
<td id="productTotal" class="rowElement3"> $3,450.00</td>
I don’t know how to sanitize the value, so that part has not been included yet.
Thanks!
I think you need to make a few changes, try something like this:
Read the comments!