document.getElementsByName("myList")返回的是一个数组var lists=document.getElementsByName("myList");
if(lists.length>0){
document.writeln(lists[0].value);
}
if(lists.length>0){
document.writeln(lists[0].value);
}
解决方案 »
- js文件追踪问题
- js能否在图片上做标记?或有什么第三方类库可以调用?
- 删除head元素
- window.onload=function()这个方法在一个页面中不能出现多次?
- web 上 ActiveX 音频传送的问题
- 麻烦给看一下,这几行javascript脚本怎么了?为什么在浏览器中显示不出来数组的值?
- 能不能屏蔽弹出窗口的关闭按钮?
- 输入中不能含有汉字的正则表达式该怎么写
- 提问:关于网页中用Javascript实现对已封装的控件*.ocx的调用方法
- ============= 关于标识符 ===============
- http://expo.pharmnet.com.cn/网站上的层效果怎么做法?
- 菜鸟问题: <input type="text" name="text2" id="text2"> id 和 name 的区别
function a(){
var ListValue=document.getElementsByName("myList")[0].value;//select对象选中的值
document.writeln(ListValue);
}
</script>
document.getElementsByName("myList")[0].selectedIndex返回所选中元素的索引数
var ListValue=List.options[List.selectedIndex].value
<head>
<script language="JavaScript">
function a(){
var ListValue=document.getElementById("myList").value
document.writeln(ListValue);
}
</script>
</head><body>
<select id="myList">
<option value="34">天f好 --> 13首</option>
<option value="35">天fg下大adf好 --> 12首</option>
<option value="38">天下大gfdadf --> 18首</option>
<option value="43">天下dfadf好 --> 9首</option>
</select><p onclick="a()">abc</p></body>
</html>
function a(){
var ListValue=document.getElementsByName("myList")[0].value;//select对象选中的值
document.writeln(ListValue);
}
</script>
document.getElementsByName("myList")[0].selectedIndex返回所选中元素的索引数