Subject: | get selection from single select list |
function getVal(id) {
if (id.constructor == Function ) { return id(); }
if (typeof(id)!= 'string') { return id; }
var element = document.getElementById(id) ||
document.forms[0].elements[id];
if(!element){
alert('ERROR: Cant find HTML element with id or name: ' +
id+'. Check that an element with name or id='+id+' exists');
return 0;
}
if(element.type == 'select-one') {
return element[element.selectedIndex].value
} ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~
in case of: nothing selected
Error: element[element.selectedIndex] has no properties