Sel为你的下拉列表框,Value为你要的值
function setSelect(Sel,Value){
//在所有Option中查找Value,然后设为当前选择 if (typeof(Sel)!='object') return;//没有对象 //alert(Value);
var iInt = Sel.selectedIndex;
for (i=0; i<Sel.length;i++){
Sel.selectedIndex = i ;
if (Sel.value==Value){
break;
}
else {
Sel.selectedIndex=iInt;
}
}
}

解决方案 »

  1.   

    <html>
    <body>
    <select id=ddl>
    <option value="a">a</option>
    <option value="b">b</option>
    </select>
    <button onclick="ddl.value='b'">test</button>
    </body>
    </html>
      

  2.   

    如果已经另外定义了value的话试试这样:
    <html>
    <body>
    <select id=ddl>
    <option value="1">a</option>
    <option value="2">b</option>
    </select>
    <button onclick="selectByText('b')">test</button>
    </body>
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    function selectByText(str)
    {
    with (ddl)
    for (var i=0;i<options.length;i++)
    if (options[i].innerText==str)
    options[i].selected=true
    }
    //-->
    </SCRIPT>
    </html>
      

  3.   

    emu(ston)'s solution is fine, except change innerText to text
    if (options[i].innerText==str)
    ===>
    if (options[i].text==str)if you want to do it on the server side, try something likefor (int i=0; i < DropDownList1.Items.Count; i++)
    {
          if (DropDownList1.Items[i].Text.Equals("b"))
          {
                DropwDownList1.SelectedIndex = i;
                break;
          }
    }
      

  4.   

    在javascript下面用value,就可以了,
    DropwDownList1.value="b"就可以了.
      

  5.   

    saucer(思归):
    用text有的时候访问不到,不知是什么原因,所以我一直用innerText