2011-04-26 85 views

回答

0

如果您使用jQuery(你应该考虑的,因为它的真棒),你可以做到这一点通过以下操作

<script type="text/javascript"> 
    $(function)({ 
     $('select[name="sel_Option"]').val('1'); 
    }); 
</script> 
0

在JavaScript中,一旦你的参考select元素(通过getElementByIdgetElementsByName),你可以使用

function setSelected(selectBox, valueToSelect){ 
    selectBox.value = valueToSelect; 
} 

http://jsfiddle.net/nogoodatcoding/DSqXe/

你ç乌尔德也使用selectedIndex属性:

function setSelected(selectBox, value){ 
    for(var i = 0; i < selectBox.length; i++){ 
     if(selectBox.options[i].value === value){ 
      selectBox.selectedIndex = i; 
     } 
    } 
} 

http://jsfiddle.net/nogoodatcoding/DSqXe/1/