读书人

js动态加载DropDownList清空怎么实现

发布时间: 2013-06-25 23:45:41 作者: rapoo

js动态加载DropDownList,清空如何实现
我想在执行 switch之前将DropDownList清空

<asp:TableRow Height="40">
<asp:TableCell ID="TableCell7" runat="server" CssClass="tb_edit_text" BackColor="#CFDEE9">
<asp:Label ID="Label8" runat="server" Width="90px" Text="选择" CssClass="tb_edit_label" />
<asp:DropDownList runat="server" ID="yslx">

</asp:DropDownList>
<asp:Label ID="biaoti" runat="server" style="color:Red" CssClass="tb_edit_label" Text="" />
</asp:TableCell>

</asp:TableRow>
<script type="text/javascript">
switch(d)
   {
   case 1:
   document.all("yslx").add(new Option("1","1"));
   break
   case 2:
   document.all("yslx").add(new Option("2","2"));
   break
......    
}
[解决办法]
document.getElementById("<%=yslx.ClientID %>").removeChild(document .getElementById ("<%=yslx.ClientID %>").firstChild )

读书人网 >JavaScript

热点推荐