日期:2014-05-18  浏览次数:20718 次

怎样用JS为dorpdownlist赋默认值
<asp:DropDownList style="float:left;" ID="DDL_ShowCompanyName" runat="server" OnSelectedIndexChanged="DDL_NewsTName_SelectedIndexChanged"
  AutoPostBack="True">
  </asp:DropDownList>


<asp:DropDownList ID="DDL_CompanyName" runat="server" Width="155px">
  </asp:DropDownList>


用JS把第一个的选中值赋给第二个当作默认值


请帮忙







------解决方案--------------------
s1 = document.getElementById('<%=DDL_ShowCompanyName.ClientID%>')
s2 = document.getElementById('<%=DDL_CompanyName.ClientID%>')

for(i=0;i<s2.options.length;i++)
{
 if(s2.options[i].value==s1.value) s2.options[i].selected=true
}