1. 程式人生 > >select標籤如何傳遞選中option的value值與text值

select標籤如何傳遞選中option的value值與text值

<select name="type" onchange="show_sub(this.options[this.options.selectedIndex].value)">    
    <option value="0">請選擇主菜名</option>    
    <option value="1">白菜</option>    
    <option value="2">蘿蔔</option>    
 </select> 

<select name="type" onchange="show_sub(this.options[this.options.selectedIndex].text)">    
    <option value="0">請選擇主菜名</option>    
    <option value="1">白菜</option>    
    <option value="2">蘿蔔</option>    
 </select>