Code
1 <script language="javascript">
2 var ddl = document.getElementById('ddl_SortID');
3 var itemCount = ddl.options.length;
4 for (var i = 0; i < itemCount; i ++)
5 {
6 //让Value="2"的那一项选中
7 //也可以用ddl.value = "2";
8 if (dd1.options[i].value == '2')
9 {
10 ddl.selectedIndex = i;
11 }
12
13 //让Text="C"的那一项选中
14 if (dd1.options[i].innerText == 'C')
15 {
16 ddl.selectedIndex = i;
17 }
18
19 //删除A项
20 if (dd1.options[i].innerText == 'A')
21 {
22 ddl.removeChild(ddl.options[i]);
23 }
24
25 //4添加value='4' text='D' 这一项
26 var optNew = document.createElement('option');
27 optNew.text = 'D';
28 optNew.value = '4';
29 try
30 {
31 ddl.add(optName);//仅对IE
32 }
33 catch(ex)
34 {
35 ddl.add(elOptNew, null); //对非IE
36 }
37 }
38 </script>
posted @
2008-07-30 13:44
flat_peach
阅读(
199)
评论()
编辑
收藏
举报