/** * Returns value of selected option in listbox * If there is no options selected - returns null. * If multiple options selected - returns first. */ function selected(sel){ if(!sel.options){ return null; } for(var i = 0; i< sel.options.length; i++){ if(sel.options[i].selected){ return sel.options[i].value; } } return null; } /** * Returns value of checked radiobutton in radiobuttons group * If there is no radiobuttons checked - returns null. */ function selectedRadio(sel){ if(!sel){ return null; } if(!sel.length){ if(!sel.checked){ return null; } return true; } for(var i = 0; i< sel.length; i++){ if(sel[i].checked){ return sel[i].value; } } return null; } /** * Returns true if one of options in radiogroup is checked; */ function isChecked(sel){ return selectedRadio(sel) != null; }