如何使用javaScript </asp:dropdownlist>在<asp:dropdownlist>中选择第一个列表项

时间:2014-03-10 09:36:04

标签: asp.net

这是我的代码

<asp:DropDownList id="lue1" runat="server">
     <asp:ListItem Selected="True" Value=" - Select One - "> - Select One - 
     </asp:ListItem>
      <asp:ListItem Value="Silver"> Silver </asp:ListItem>
      <asp:ListItem Value="DarkGray"> Dark Gray</asp:ListItem>
      <asp:ListItem Value="Khaki"> Khaki </asp:ListItem>
      <asp:ListItem Value="DarkKhaki"> Dark Khaki </asp:ListItem>
</asp:DropDownList>
<br />
<a class="bullet blt-add" id="lnkAddAnother1" href="javascript:" 
   onclick="ShowNextCountrol(this,2)">Add Another</a>

功能ShowNextCountrol会显示另一个dropdownlistselected listitem将是第一个

2 个答案:

答案 0 :(得分:0)

试试这个

 document.getElementById("lue1").selectedIndex = 0;

答案 1 :(得分:0)

function setSelectedIndex(s, i)
{
    s.options[i-1].selected = true;
    return;
 }
 setSelectedIndex(document.getElementById("lue1"),2);

//在2的位置给出你需要的位置

相关问题