Dropdownlist可输入,可选择的方法

80酷酷网    80kuku.com

  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" 100; LEFT: 48px; VISIBILITY: visible; CLIP: rect(0px 110px 80px 92px); POSITION: absolute; TOP: 26px">
<asp:dropdownlist id="DDLTitle" -1" runat="server" Width="110"></asp:dropdownlist>
</div>
<asp:textbox id="txtTitle" 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


分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: