我正在使用this guide以价格形式添加计算,将其乘以数量(按下拉列表设置)并输出为总数。
我的最终代码是:
function totalQuantity(){
getPrice_6();
//calculate a grand total based on the available product field
quantity = parseInt(document.getElementById('quantity').value);
//retrieve the value selected in the "quantity" field
currentTotal = parseFloat(document.getElementById('total').value);
//adjust displayed total
total = quantity * currentTotal;
//re-calculate the total based on the value selected in the "quantity" field
document.getElementById('total').value = total.toFixed(2);
//convert the "total" field's value to a float number followed by 2 decimals
document.getElementById('payment_total_6').innerHTML = total.toFixed(2) + ' AUD';
//display the total field's value along with the "USD" currency code
document.getElementsByName('form[rsfp_Total]')[0].value = total.toFixed(2);
return true;
}
window.addEvent('domready', function() {
totalQuantity();
});
但是在更改数量字段时,我收到一个控制台错误:未捕获的ReferenceError:未定义getPrice_6。
根据指南,'6'是我正在使用的表单的ID。
似乎我错过了一些明显的东西,但我无法弄清楚是什么。