jQuery .click で起動するように、ストレートな javacript 関数を変換しようとしています。
出力エラーは発生していませんが、jsfiddle で計算を実行しません。
var form = document.product_form_top;
function process(v) {
var value = parseInt(document.getElementById('item_qty').value);
value += v;
document.getElementById('item_qty').value = value.toFixed(0);
}
function calculate() {
form.cubicYards.value = (form.length.value / 3) * (form.width.value / 3) * (form.depth.value / 35);
document.getElementById('yards').innerHTML = finaloutput
var number = parseFloat(form.item_qty.value);
var finaloutput = number.toFixed(0);
form.item_qty.value = form.cubicYards.value * 14.7; //calculate yards
var number = parseFloat(form.cubicYards.value);
var finaloutput = number.toFixed(0);
document.getElementById('item_qty').innerHTML = finaloutput
form.weightPounds.value = (form.length.value / 3) * (form.width.value / 3) * (form.depth.value * 21);
form.weightPounds.value * 700;
var number = parseFloat(form.weightPounds.value);
var finaloutput = number.toFixed(0)
document.getElementById('pounds').innerHTML = finaloutput
}
ここにjsfiddleがあります http://jsfiddle.net/4L4St/8/
ボタンで onclick="calculate(); を使用して関数を実行する作業バージョンを次に示します。むしろ、jQuery の .click 関数を使用して起動します。
http://spartonenterprises.com/store/playground-mulch
また、 toFixed(0) を使用して余分な小数点を削除していますが、firebugで検査すると機能するように見えますが、表示されるhtmlには小数点が表示されます。変?