开发者

issue with ajax combox control

开发者 https://www.devze.com 2022-12-07 23:58 出处:网络
i am using ajaxcombo boxcontrol. Here i haveitems like kiran james alice dinesh prakash manu if usertypetheword like\"kushal\" as thiswordisnot therein theitemsof thecontrolthiswordshould notbeset

i am using ajax combo box control. Here i have items

like

  • kiran james alice dinesh prakash manu

if user type the word like "kushal" as this word is not there in the items of the control this word should not be set in combo box control. but if the word is there in controls it should be allowed to set in the control

hope my Question is clear. thank 开发者_运维技巧 you


I don't really understand your question, is this what you mean?

<input id="name" type="text" onkeyup="selectItem(this.value)" />
<select id="combo">
    <option>kiran</option>
    <option>james</option>
    <option>alice</option>
    <option>dinesh</option>
    <option>prakash</option>
    <option>manu</option>
</select>
<script>
  function selectItem(name){
     var combo = document.getElementById('combo');
     for(var i=0;i<combo.options.length;i++){
        if(combo.options[i].text == name){
           combo.options[i].selected = true;
           combo.selectedIndex = i;
           combo.value = name;
        }
     }
  }
</script>

or the shorter version:

 <input id="name" type="text" onkeyup="document.getElementById('combo').value=this.name;" />
0

精彩评论

暂无评论...
验证码 换一张
取 消