0
我想爲我的貝寶付款選項創建價格計算。我使用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="[email protected]">
<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
它不起作用! – 2011-06-17 04:19:54
還使用onsubmit屬性在form標籤中添加calculate()函數。