먼저 한 후 카트 총을 추가하는 것은, 여기 : 누군가가 오른쪽 하단에있는 "소계"를 업데이트 할 수 있습니다 항목의 수량을 업데이트 할 때 http://webapps.bcit.ca/A00839579/MDIA3207/Assign4/cart.html자바 스크립트 : 수량 변화
기본적으로, 내가 좋아하는 것입니다. 너무 열심히해서는 안되지만, 웬일인지 그것을 이해할 수는 없습니다. 그리고 부수적으로, 수량이 업데이트 될 때 어떻게 소수를 사용하여 가격을 유지할 수 있는지 파악할 수 있다면 좋을 것입니다. 정말 고마워!
var artprice = 28.99;
var artquantity = document.getElementById("artquantity").value;
var arttotal = (artprice * artquantity).toFixed(2) - 0;
var loverprice = 19.95;
var loverquantity = document.getElementById("loverquantity").value;
var lovertotal = (loverprice * loverquantity).toFixed(2) - 0;
var nightprice = 32.00;
var nightquantity = document.getElementById("nightquantity").value;
var nighttotal = (nightprice * nightquantity).toFixed(2) - 0;
function artupdate() {
var subtotal = arttotal + lovertotal + nighttotal;
var artprice = 28.99;
var artquantity = document.getElementById("artquantity").value;
var arttotal = (artprice * artquantity).toFixed(2) - 0;
document.getElementById("artprice").innerHTML = "$" + arttotal;
document.getElementById("subtotal").innerHTML = "$" + subtotal;
}
function loverupdate() {
var subtotal = arttotal + lovertotal + nighttotal;
var loverprice = 19.95;
var loverquantity = document.getElementById("loverquantity").value;
var lovertotal = (loverprice * loverquantity).toFixed(2) - 0;
document.getElementById("loverprice").innerHTML = "$" + lovertotal;
document.getElementById("subtotal").innerHTML = "$" + subtotal;
}
function nightupdate() {
var subtotal = arttotal + lovertotal + nighttotal;
var nightprice = 32.00;
var nightquantity = document.getElementById("nightquantity").value;
var nighttotal = (nightprice * nightquantity).toFixed(2) - 0;
document.getElementById("nightprice").innerHTML = "$" + nighttotal;
document.getElementById("subtotal").innerHTML = subtotal;
}
var subtotal = arttotal + lovertotal + nighttotal;
document.getElementById("subtotal").innerHTML = "$" + subtotal;
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}
제거 -0이 0 내가 종류의 내 주요 문제를 파악 – mplungjan
후행 한 경우에서는 toFixed을 취소하지만이 변경되면되는 첫 번째 숫자의 수량은 $ 28.99이고 1 대신 3 개의 수량이됩니다.이 값은 86.97 + 19.95 + 32.00이고 138.92와 같습니다. 그러나 첫 번째 숫자의 수량을 3으로 변경하고 첫 번째 숫자를 변경 한 후에 두 번째 숫자를 3의 수량으로 변경하면 3 개의 수량과 다른 두 개의 중간을 1 개의 수량으로 추가합니다 . 0을 제거하면이 "28.9919.9532.00"과 같은 3 개의 숫자가 소계로 추가됩니다. 그러나 나는 그 모든 숫자가 합쳐지기를 원하고 두 개의 십진법을 병행하지 않고 그와 나란히 놓기를 원합니다. –