function showNumber(selectId, divNumber) {
//this takes value from select option and grabs div for displaying it
var select = document.getElementById(selectId);
var noItems = document.getElementById(divNumber);
//loop for creating 0-20 drop down
for (var i = 0; i <= 20; i++) {
var option = document.createElement('option');
option.innerHTML = i;
option.value = i;
select.appendChild(option);
}
//onchange shows in a div how many items were selected
select.onchange = function () {
var noZero = select.value;
if (noZero > 0) {
noItems.innerHTML = noZero;
} else noItems.innerHTML = " ";
};
}
//function takes parameters of the previous one and displays number of items of a particular product in a div
function showDivs(){
showNumber('item1', 'div1');
showNumber('item2', 'div2');
showNumber('item3', 'div3');
showNumber('item4', 'div4');
}
我的问题是我想添加所有产品(item1、item2 等)的数量以计算它们的总数。我似乎没有得到任何帮助,非常感谢任何帮助!...