Following is a function that will help you retrieve the value selected in a HTML Combobox.
function getComboValue(comboBoxID) {
var comboObj=document.getElementById(comboBoxID);
var comboValue=document.all?comboObj.options[comboObj.selectedIndex].text:comboObj.options[comboObj.selectedIndex].value;
return (trim(comboValue,"\n"));
}
function trim(str, chars) {
return ltrim(rtrim(str, chars), chars);
}
function ltrim(str, chars) {
chars = chars || "\\s";
return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
function rtrim(str, chars) {
chars = chars || "\\s";
return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
No comments:
Post a Comment