Sunday, March 31, 2013

Java Script to Add Remove Select Options


function  demoFun(){

var countryIdJS = document.getElementById("countryId").value;

var regionSelect = document.getElementById('regionId');

regionSelect.options.length = 0; // delete all existing options

regionSelect.options[0] = new Option ("--Select--","0");
         // above line will add new option with value "0" and displayText "--Select--"

regionSelect.options[0].selected="true";

          // above line will select the 0 th option 

}