[导入]js select
已经验证,可供参考!
//用数组给select加options列表项
selectName.options[i]=new options("option_value","option_Text");
selectName.options[i].selected=true;
selectName.options[i]=new options("option_value","option_Text");
selectName.options[i].selected=true;
//例子
<select name="hi" onchange="getSelect('hi');">
<option value="01">一</option>
<option value="02">二</option>
<option value="03">三</option>
<option value="04">四</option>
</select>
//获得value值 如“01”,注意selectedIndex从 0 开始,离开form1访问时要用document.form1.selectName.options[form1.selectName.selectedIndex].value
value = form1.selectName.options[form1.selectName.selectedIndex].value
//获得text值,如“一”
text = form1.selectName.options[form1.selectName.selectedIndex].text
//或
text = form1.selectName.options[form1.selectName.selectedIndex].innerHTML
<select name="hi" onchange="getSelect('hi');">
<option value="01">一</option>
<option value="02">二</option>
<option value="03">三</option>
<option value="04">四</option>
</select>
//获得value值 如“01”,注意selectedIndex从 0 开始,离开form1访问时要用document.form1.selectName.options[form1.selectName.selectedIndex].value
value = form1.selectName.options[form1.selectName.selectedIndex].value
//获得text值,如“一”
text = form1.selectName.options[form1.selectName.selectedIndex].text
//或
text = form1.selectName.options[form1.selectName.selectedIndex].innerHTML
文章来源:http://www.phpweblog.net/fuyongjie/archive/2008/07/02/5262.html