现在我有一个需求,现在我有一个select框 我要用js给这个select赋值 要显示的值在这个select里面已经有了 但是问题是我现在赋值text的话等于给select框加了一个选项,但是我现在要复制的时候只取到了select框里面的name,没有Value
请问怎么做?

解决方案 »

  1.   

    我感觉我也没说明白 这么说吧我现在有一个select和一个text
    现在我的select是这样的
     <select name="name" orteus="true">
         <option></option>
         <option value="1">AAA</option>
     </select>
    我现在想在text里面输入AAA的时候就让select显示AAA,注意text里面不能输入value值
    怎么做?
      

  2.   

    <input id="text1" type="text" />
    <select id="name" name="name" orteus="true">
      <option></option>
      <option value="1">AAA</option>
    </select>
        window.onload = function() {
             var input = document.getElementById('text1');
             input.onkeyup = function() {
                 var select = document.getElementById('name');
                 for (var i = 0, count = select.options.length; i < count; i++) {
                     if (select.options[i].text == input.value) {
                         select.selectedIndex = i;
                         break;
                     }
                 }
             }
         }
      

  3.   


    <script>
    function test(val){
      var sel=document.getElementById('sel');
      for(var i=0;i<sel.options.length;i++)
      {
       if(sel.options[i].text==val)
       {
       sel.options[i].selected=true;
       break;
       }
      }
    }
    </script>
    <select id="sel" name="name" orteus="true">
        <option> </option>
        <option value="1">AAA </option>
    </select> 
    <input type="text" stype="width:100px;" onblur="test(this.value)" />
      

  4.   

    orteus= true   是什么意思呀?