I. Insert Option
1. DOM method
VaR oselectyear = Document. getelementbyid ("selectyear ");
VaR op = Document. createelement ("option ");
Op. innerhtml = "2010 ";
Op. value = "2010 ";
Oselectyear. appendchild (OP );
2. New Option Method
VaR oselectmonth = Document. getelementbyid ("selectmonth ");
Oselectmonth. Options. Add (New Option (1, 1 ));
Oselectmonth. Options. Add (New Option (2, 2 ));
Ii. Clear Option
VaR oselectmonth = Document. getelementbyid ("selectmonth ");
Oselectmonth. Options. Length = 0; // clear options in select
3. Set the default option
var oselectmonth = document. getelementbyid ("selectmonth");
// oselectmonth. selectedindex = 1; // Method 1: The second item is selected by default
// setTimeout (function () {oselectmonth. selectedindex = 1 ;}, 0); // the setTimeout delay is used to prevent Dom rendering problems
// oselectmonth. options [1]. selected = true; // method 2
oselectmonth. options [1]. setattribute ("selected", "true"); // method 3: setattribute is recommended.