DropDownList实现可输入可选择(两种版本可选)
1、js版本
<divstyle="z-index:0;visibility:visible;clip:rect(0px105px80px85px);position:absolute">
<asp:DropDownListID="ddlModel"runat="server"Style="z-index:-1"Width="105px"
onchange="getModelTo(this)">
<asp:ListItemValue="1">SSM-001</asp:ListItem>
<asp:ListItemValue="2">DDW-523</asp:ListItem>
<asp:ListItemValue="3">QSD-009</asp:ListItem>
</asp:DropDownList>
</div>
<asp:TextBoxID="txtModel"runat="server"Style="z-index:1px;position:absolute"
Font-Size="9pt"Width="95px"Height="16px"MaxLength="50"></asp:TextBox>
<scripttype="text/javascript">
functiongetModelTo(e){
document.getElementById("txtModel").value=e.options[e.selectedIndex].innerText;
document.getElementById("txtModel").select();
}
</script>
2、jquery版本
<divstyle="z-index:0;visibility:visible;clip:rect(0px105px80px85px);position:absolute">
<asp:DropDownListID="ddlModel"runat="server"Style="z-index:-1"Width="105px"
onchange="getModelTo(this)">
<asp:ListItemValue="1">SSM-001</asp:ListItem>
<asp:ListItemValue="2">DDW-523</asp:ListItem>
<asp:ListItemValue="3">QSD-009</asp:ListItem>
</asp:DropDownList>
</div>
<asp:TextBoxID="txtModel"runat="server"Style="z-index:1px;position:absolute"
Font-Size="9pt"Width="95px"Height="16px"MaxLength="50"></asp:TextBox>
<scripttype="text/javascript">
functiongetModelTo(e){
$("#txtModel").val($("#ddlModel").find("option:selected").text());
$("#txtModel").select();
}
</script>
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流,同时也希望多多支持毛票票!
热门推荐
10 新年十一祝福语大全简短
11 文案写信祝福语大全简短
12 儿子生日老公祝福语简短
13 闺女结婚红包祝福语简短
14 横幅祝福语大全简短霸气
15 鼠年女孩生日祝福语简短
16 中考送给老师祝福语简短
17 分手后祝福语简短高级
18 英文邮件假期祝福语简短