Dropdownlist可输入,可选择的方法
function addTxtTanto(va){document.all("txtTitle").value=va; document.all("txtTitle").select();
}
function checktitle(){
var drp = document.all("DDLTitle");
var t=document.all("txtTitle");
var j=0;
if(t.value==""){
}else{
for(var i=0;i<drp.length;i++){
if(t.value==drp.options(i).text){
drp.value=drp.options(i).value;
break;
}else{
j=j+1;
}
}
if(j==drp.length){
t.value="";
t.select();
alert("タイトルが存在していません。");
}
}
}
<div id="selDiv" style="Z-INDEX: 100; LEFT: 48px; VISIBILITY: visible; CLIP: rect(0px 110px 80px 92px); POSITION: absolute; TOP: 26px">
<asp:dropdownlist id="DDLTitle" style="Z-INDEX: -1" runat="server" Width="110"></asp:dropdownlist>
</div>
<asp:textbox id="txtTitle" style="Z-INDEX: 103; LEFT: 47px; POSITION: absolute; TOP: 26px" runat="server" Font-Size="10" Width="111" maxLength="50" Height="22"></asp:textbox>
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load txtTitle.Attributes("onblur") = "javascript:checktitle();"
DDLTitle.Attributes.Add("Onchange", "addTxtTanto(this.options[this.selectedIndex].innerText)")
end sub
补充:asp教程,高级应用