关于下拉选择框问题

在网页中有一个下拉列表框,供用户选择自己所在城市。他们如下所示:

1<select id="sel_city" name="sel_city">
2<option value="0">北京</option>
3<option value="1">上海</option>
4<option value="2">杭州</option>
5</select>

现在的问题是:当我选中选择框时,输入“北京”,那么“北京”就会被选中,同样输入“上海”,那么“上海”就会被选中。
可是输入“杭州”时,光标就不动了。为什么????

请各位大侠出招吧!!!
---------------------------------------------------------------

1<select id="sel_city" name="sel_city">
2<option value="0">北京</option>
3<option value="1">上海</option>
4<option value="2">杭州</option>
5</select>
1<input onblur="for(i=0;i&lt;sel_city.options.length;i++){ if(sel_city.options[i].text==this.value) sel_city.options[i].selected=true}"/>

---------------------------------------------------------------

自己再改善

 1<body>
 2<script>   
 3function check(v){   
 4var n=0   
 5if(!v)return;   
 6for(i=0;i<sel_city.options.length;i++){   
 7if(sel_city.options[i].text.indexOf(v)==0){sel_city.options[i].selected=true;n++}   
 8}   
 9if(n==0)alert('sorry,no data you found')   
10}   
11</script>
12<select id="sel_city" name="sel_city">
13<option value="0">北京</option>
14<option value="1">上海</option>
15<option value="2">杭州</option>
16</select>
17<input onkeyup="check(value)"/>
18</body>
Published At
Categories with Web编程
comments powered by Disqus