我想为我的Paypal付款选项创建价格计算。我正在使用javascript来做到这一点。但它不起作用。所以有人可以帮助我吗?以下是代码:
<script LANGUAGE="JavaScript">
function dp(price) {
string = "" + price;
number = string.length - string.indexOf('.');
if (string.indexOf('.') == -1) return string + '.00';
if (number == 1) return string + '00';
if (number == 2) return string + '0';
if (number > 3) return string.substring(0, string.length - number + 3);
return string;
}
function calculate() {
document.calcform.total1.value = dp((document.calcform.amount.value) * (document.calcform.quantity1.value))
}
</script>
<p>number of licenses (US$59.99 per license):</p>
<p><form name="calcform" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_xclick">
<input type="hidden" name="business" value="sample@paypal.com">
<input type="hidden" name="lc" value="MY">
<input type="hidden" name="item_number" value="abc">
<input type="text" name="quantity1" size="50" ONCHANGE="calculate()">
<input type="hidden" name="amount" ONCHANGE="calculate()" value="59.99">
<input type="hidden" name="item_name" value = "J-2011">
</form></p>
enter to process payment
答案 0 :(得分:1)
在表单标记内添加名为“total1”的隐藏框。
<input type="hidden" name="total1" value = "">