<select id="edu" name="edu">
<option value="高級">博士</option>
<option value="中級">碩士</option>
<option value="初級" selected="selected">本科</option>
<option value="低級">大專</option>
</select>
<script>
var a=document.getElementById('edu');
alert("選擇欄位的值:"+a.value);
//顯示selelct內的option欄位頁面
alert("a.innerHTML:"+a.innerHTML);
/*遍歷option 方法1*/
/*var b=a.getElementsByTagName("option");
for(var i=0;i<b.length;i++){
var bb=b[i];
var bbb=bb.firstChild;
alert("option子元素的nodeValue"+bbb.nodeValue);
}*/
/*遍歷option 方法2*/
/*var c=a.options;
for(var i=0;i<c.length;i++){
//var cc=c[i].value;//獲取value
var cc=c[i].text;//獲取option之間的text
alert("="+cc);
}*/
var dd=a.options[a.selectedIndex].text;
alert("顯示欄位選擇的文本:"+dd);
</script>