车神

专注MS.NET技术
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

筛选selected

Posted on 2010-03-10 19:27  车神  阅读(115)  评论(0)    收藏  举报

 

代码
<script type="text/javascript">
        
var all = "";
        
var indexid = "0";
        
function chooseSelect()
        {
            s 
= document.getElementById("myselect");
            ops
= s.options;
            
if(all != document.getElementById("Text1").value)
            {
                indexid 
= "0";
            }
            all 
= document.getElementById("Text1").value;
            
for(var i=0; i<s.length; i++)
            {
                
if(ops[i].text.indexOf(all) > -1)
                {
                    
if(parseInt(indexid) < parseInt(ops[i].value))
                    {
                        indexid 
= ops[i].value;
                        s.options[i].selected
=true;
                        
break;
                    }
                }
            } 
        }
    
</script>