Return to Snippet

Revision: 23977
at February 17, 2010 23:25 by desmond54


Initial Code
function addSelectOption(formName, selectName, optionValue, optionText, insertIndex, selectedOptionIndex) {
    var newOpt = document.createElement("option");
    newOpt.value = optionValue;
    newOpt.text = optionText;
    var selectElement = eval("document." + formName + "." + selectName);
    selectElement.add(newOpt, selectElement.options[insertIndex]);
    selectElement.selectedIndex = selectedOptionIndex;
}

Initial URL


Initial Description


Initial Title
Add OPTION to SELECT

Initial Tags
javascript

Initial Language
JavaScript