I'm trying to get my addItem to read the data from another one and then write it back to the dom. It all works fine with one variable at a time, but not when I try and concat or append them together. After the append or concat function the variable listAdd reads as "[object text] [object text]" in firebug. when it should just read as a one value.
// calculates price
function calcPrice() {
var price = document.getElementById("price").value;
var quantity = document.getElementById("quantity").value;
var total = price * quantity;
return total;
};
// adds item to dom
document.getElementById("add").onclick = function addItem(){
var newItem = document.getElementById("item").value;
var li=document.createElement("li");
var item = document.createTextNode(newItem);
var total = document.createTextNode(calcPrice());
var listAdd = item + total;
li.append(listAdd);
$("receipt").appendChild(li);
};
// removes last li element from ul
document.getElementById("remove").onclick = function removeItem(){
$("li:last-child").remove();
};