I'm not a javascript brainiac, and am having some problems integrating a VERY simple code in the "add/edit product" area. I want to add a button next to the "group price" that when clicked calculates the group price as a percent of the retail price (I haven't yet had success with Easy Populate including that info). My problem comes from the fact that the separate price per customer field name contains square brackets, and this complicates the javascript code. I've looked into escaping the characters in the script, utilizing special characters for '[' and']', and treating the form field as an element referenced by index, all to no avail. The imortant part of the code follows. Could someone PLEASE just tell me what to change to make this work. I've spent way to much time on this simple problem.
Quote:
<html>
<head>
<script>
function CalcDiscount()
{
var RetailPrice = eval(document.new_product.products_price.value)
var Discount = .75
document.new_product.sppcprice[1]; = RetailPrice * Discount
}
</SCRIPT>
</head>
<body>
<form name="new_product">
<input type="text" name="products_price" size="4"><br><br>
<input type="text" name="sppcprice[1]" size="4">
<input type="button" value="Recalculate" onClick="CalcDiscount()">
</form>
</body>
</html>
|
Thank in advance,
Spice