<input type="checkbox" onchange = 'rower();' id="one" name="Стол" value="100" />
<input type="checkbox" onchange = 'rower();' id="two" name="+Стул" value="200" />
<h3 id="summa" > </h3>
function rower() {
var x=document.getElementsByTagName("input");
var summa=document.getElementById('summa');
var msg='';
var price=0;
for (var i = 0 ;i<x.length; i++)
{
if (x[i].checked){
msg +=x[i].name ;
price +=parseInt(x[i].value) ;
summa.textContent= msg+ '=' + price ;
}
else{
summa.textContent=' ' ;
}
}
}
function rower() {
var x=document.getElementsByTagName("input");
var summa=document.getElementById('summa');
var msg='';
var price=0;
summa.textContent='';
for (var i = 0 ;i<x.length; i++) {
if (x[i].checked) {
msg +=x[i].name;
price +=parseInt(x[i].value);
summa.textContent= msg+ '=' + price;
}
}
}
<input type="checkbox" onchange="check(this)" id="item-1" />
<input type="checkbox" onchange="check(this)" id="item-2" />
<h3 id="summa">Выберите элемент</h3>
var items = {
"1": {name: "Стол", price: 100},
"2": {name: "Стул", price: 200}
};
function check(input) {
var id = input.id.split('-')[1];
items[id].checked = input.checked;
updateSum();
}
function updateSum() {
var sum = 0, names = [];
for (var i in items) {
if (items[i].checked) {
names.push(items[i].name);
sum += items[i].price;
}
}
var text = "Выберите элемент";
if (sum > 0) text = names.join('+') + '=' + sum;
document.getElementById('summa').textContent = text;
}