Posted By

krisdb on 03/09/07


Tagged

javascript


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

vali29


new select box option


 / Published in: JavaScript
 

  1. <select onChange="checkNew(this);" name="selectName">
  2. <option value="0">Add new...</option>
  3. </select>
  4.  
  5. <script LANGUAGE="JavaScript" TYPE="text/javascript">
  6. function checkNew(frm) {
  7.  
  8. var selectedOption = frm.selectedIndex;
  9. var selectedValue = frm.options[selectedOption].value;
  10. var selectedText = frm.options[selectedOption].text;
  11.  
  12. if (selectedValue == '0') {
  13. var newOption = prompt('Enter new ','');
  14. frm.options[frm.options.length] = new Option(newOption,newOption,true);
  15. }
  16. }
  17. </script>

Report this snippet  

You need to login to post a comment.