开发者

adding options to drop down box dynamically

I want to dynmically add some options to drop down box.but i want to mark one of them as selected .How can i do it?

DropdownBox = document.getElementById("xyzid");
 var optn = document.createElement("OPTION");
 optn.text="txt";
 optn.value="value";
 DropdownBox.options.add("values");

the above code is executed inside l开发者_JS百科oop with diff values .How can i mark one as selected?


DropdownBox.options[0].selected = true;

Change the index as needed.

Update:

HTML/JavaScript - Choose dropdown options using JavaScript

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜