写JS的时候 获取select对象的value是很常见的事情 例如
<script language="javascript">
function selectInput(choose)
{
alert(choose.value);
}
</script>
<select name="month" οnchange="selectInput(this)">
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08" selected="selected">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
这样子就可以获得 month的值了 也就是01 02 03... 但是value所指向的text呢? 用一般的方法
function selectInput(choose)
{
alert(choose.text);
}
这样子是获取不到的~ 那我们则需要另一种方法获取
<script language="javascript">
function selectInput(choose)
{
alert(choose.options[choose.selectedIndex].text);
}
</script>
<select name="Month" οnchange="selectInput(this)">
<option value="01">January</option>
<option value="02">February</option>
<option value="03">March</option>
<option value="04">April</option>
<option value="05">May</option>
<option value="06">June</option>
<option value="07">July</option>
<option value="08" selected="selected">August</option>
<option value="09">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>