Hi I have a problem with retrieving first populated, than selected by user quantity from the select dropdown menu.
I have several the same numeric type of menus. They contain values 0-20.
Event onchange causes the selected number to be displayed in an html div. It works fine. However, if I try to get the selected number back from the div for my calculations, it doesn't work.
I spent hours on it, any help greatly appreciated....
function showNumber(selectId, divNumber) {
var select = document.getElementById(selectId);
var noItems = document.getElementById(divNumber);
for (var i = 0; i <= 20; i++) {
var option = document.createElement('option');
option.innerHTML = i;
option.value = i;
select.appendChild(option);
}
select.onchange = function () {
var noZero = select.value;
if (noZero > 0) {
noItems.innerHTML = noZero;
} else noItems.innerHTML = " ";
};
}
function showDivs(){
showNumber('item1', 'div1');
showNumber('item2', 'div2');
showNumber('item3', 'div3');
showNumber('item4', 'div4');
}