Код: Выделить всё
var qtyTotal = 0;
var priceTotal = 0;
function addProduct() {
var productID = document.getElementById("productID").value;
var product_desc = document.getElementById("product_desc").value;
var qty = document.getElementById("quantity").value;
// qtyTotal = qtyTotal + parseInt(qty);
//document.getElementById("qtyTotals").innerHTML=qtyTotal;
var price = document.getElementById("price").value;
//priceTotal = priceTotal + parseInt(price);
//document.getElementById("priceTotals").innerHTML=priceTotal;
var table=document.getElementById("results");
var row=table.insertRow(-1);
var cell1=row.insertCell(0);
var cell2=row.insertCell(1);
var cell3=row.insertCell(2);
var cell4=row.insertCell(3);
var cell5=row.insertCell(4);
var cell6=row.insertCell(5);
cell1.innerHTML=productID;
cell2.innerHTML=product_desc;
cell3.innerHTML=qty;
cell4.innerHTML=price;
cell5.innerHTML=' Edit';
cell6.innerHTML ='Delete';
}
function editProduct(){
document.getElementById("productID").value = productID;
document.getElementById("product_desc").value = product_desc;
document.getElementById("quantity").value = qty;
document.getElementById("price").value = price;
}
function deleteProduct(node){
r=node.parentNode.parentNode;
r.parentNode.removeChild(r);
}< /code>
Shopping Cart Pure Javascript
Product ID:
Product Desc:
Quantity:
Price:
Product ID
Product Description
Quantity
Price
Action
Подробнее здесь: https://stackoverflow.com/questions/447 ... t-function