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 好听的元旦简短祝福语