tags:

views:

16

answers:

1

hi, 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

A: 

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;" />
jerjer