Posted By

desmond54 on 02/17/10


Tagged

javascript


Versions (?)

Add OPTION to SELECT


 / Published in: JavaScript
 

  1. function addSelectOption(formName, selectName, optionValue, optionText, insertIndex, selectedOptionIndex) {
  2. var newOpt = document.createElement("option");
  3. newOpt.value = optionValue;
  4. newOpt.text = optionText;
  5. var selectElement = eval("document." + formName + "." + selectName);
  6. selectElement.add(newOpt, selectElement.options[insertIndex]);
  7. selectElement.selectedIndex = selectedOptionIndex;
  8. }

Report this snippet  

You need to login to post a comment.