Ivan Zugec

Drupal Consultant

Dynamically change select options with JavaScript

If you ever need to change a select box via javascript use the code below.


document.myFormName.mySelectName.options[2] = new Option("label", "value", true);

For more information go here http://www.javascriptkit.com/javatutors/selectcontent.shtml and http://www.javascriptkit.com/jsref/select.shtml#section2

About the author: Ivan Zugec
Ivan Zugec's picture

Ivan is a Sydney Australia based Drupal Developer with over 5 years experience.

Follow:
Category: 

Add new comment