Q: add price to array and show total sum With great help from user: PSL i´ve gotten halfway in myproject with a shopping-cart.
However, I would also like to add prices to the different products and have them all add up in 
the div="sum".
Could i maybe add another attribute to the product containing the price and loop through and sum up the total??
http://jsfiddle.net/bald1/Tw9L9/
   var cart = []; 
var cartElement = document.getElementById("cart");



function addToCart(productName) {
   cart.push(productName); 
   cartElement.innerHTML = cart.join("<br>");  
}


var products = document.getElementsByClassName('details');

for(var i=0; i < products.length; i++){
    products[i].addEventListener("click", handleClick, false);
}


function handleClick(e){
    var str = this.dataset.productname; 
    addToCart(str); 
}


A: try something like this,FIDDLE
javascript code
   var cart = [];
   var cartElement = document.getElementById("cart");



   function addToCart(obj) {
       var str = obj.dataset.productname;
       var price = obj.dataset.price;
       cart.push(str);
       cartElement.innerHTML = cart.join("<br>");
       var old_price = document.getElementById('total_sum').value;
       var new_price = parseInt(old_price) + parseInt(price);
       document.getElementById('total_sum').value = new_price;
       document.getElementById('sum').innerHTML = new_price;
   }


   var products = document.getElementsByClassName('details');

   for (var i = 0; i < products.length; i++) {
       products[i].addEventListener("click", handleClick, false);
   }


   function handleClick(e) {

       addToCart(this);
   }

HTML CODE
<div id="cart"></div>
<div class="item">
    <div class="wrapper">
        <img src="images.png" alt="">
    </div>
    <p class="details" data-productName="prod1" data-price="100">prod</p>
</div>
<div class="item">
    <div class="wrapper">
        <img src="images.png" alt="">
    </div>
    <p class="details" data-productName="prod2" data-price="200">prod2</p>
</div>
<div id="sum">
    <p>SUM</p>
</div>
<input type="hidden" id="total_sum" value="0" />

