日期:2014-05-16  浏览次数:20477 次

如何显示select里的全部内容
<form   id= "form1 "   action= " "   method= " ">
        <select   id= "aaa "   name= "a ">
        <option   value= "1 "> 浙江 </option>
        <option   value= "2 "> 杭州 </option>
        </select>
        <input   type= "button "   value= "检查选择项 "   onclick= "javascript:Foo(); ">
</form>

谢谢

------解决方案--------------------
multiple???
------解决方案--------------------
<select id= "aaa " name= "a ">
<option value= "1 "> 浙江 </option>
<option value= "2 "> 杭州 </option>
</select>
<input onclick= "javascript:Foo(); " type= "button " value= "检查选择项 ">
<div id= "div2 "> </div>
<script>
function Foo() {
var o = document.getElementById( 'aaa ').getElementsByTagName( 'option ');
var r = ' ';
for (var i = 0, l = o.length ; i < l ; i++) {
r += o[i].text + ' <br/> ';
}

document.getElementById( 'div2 ').innerHTML = r;
}
</script>
------解决方案--------------------
var Foo = function()
{
var t = form1.aaa.options;
for(var i=0;i <t.length;i++)
{
alert(t[i].text);
}
}
------解决方案--------------------
<script language= "JavaScript " src= "jquery-latest.js "> </script>
<script language= "JavaScript ">
<!--
alert($( "selectid ").text());
//-->
</script>
------解决方案--------------------
<script language= "JavaScript " src= "jquery-latest.js "> </script>
<script language= "JavaScript ">
<!--
alert($( "#selectid ").text());
//-->
</script>
------解决方案--------------------
饭前一贴,哈

L@_@K

<body>
<form id= "form1 " action= " " method= " ">
<table>
<tr>
<td>
<select id= "aaa " name= "a " style= "position: relative ">
<option value= "1 "> 浙江 </option>
<option value= "2 "> 杭州 </option>
</select>
</td>
<td valign= "top ">
<input type= "button " value= "检查选择项 " onclick= "javascript:Foo(); ">
</td>
</tr>
</table>
</form>
<script type= "text/javascript ">
<!--
function Foo()
{
var oSelect = document.getElementById( "aaa ");
oSelect.size = oSelect.options.length;
oSelect.focus();