开发者

Modifying the default value in a dropdown

I want to change the default value in a drop down.

Here is the html I am trying to modify

<SELECT name="ACCESSGROUPS" size = 1 id="ACCESSGROUPS">
 <OPTION id="Something" value="PRIVATE_PROJECT">Project Members Only</OPTION>
 <OPTION value="wt.admin.Administrati开发者_JS百科veDomain:15138">Default</OPTION>
</SELECT>

And here is the JS supposed to do it (I am inserting into the JSP generating the page)

Obj1 = document.getElementById("Something");
Obj2 = ayObj1.nextSibling;
Obj1.parentNode.insertBefore(Obj2,Obj1); //works in FF, Opera
Obj2.selected=true; //works in Chrome

For some reason it is not working in IE6. The nodes get swapped, but the default value does not change. How would I go about fixing this?


Use "selectedIndex":

ChildNodObject1.parentNode.selectedIndex=0; //or whatever value you want
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜