JavaScript获取选中项
<script type="text/javascript">
function show(){
var ListUtil=new Object();
var ListUtil.getSelectedIndexes=function (oListbox){
var arrIndexes=new Array;
for(var i=0;i <oListbox.length;i++){
if(oListbox.options[i].selected){
arrIndexes.push[i];
}
}
return arrIndexes;
};
var oListbox=document.getElementById("selAge");
var arrIndexes=ListUtil.getSelectedIndexes(oListbox);
alert("There are"+arrIndexes.length+"option selected."+"The options have the indexes"+arrIndexes+".");
}
</script>
</head>
<body onload="show()">
<select name="selAge" id="selAge" size="3" multiple="multiple">
<option value="1" >18-21 </option>
<option value="2" selected="selected">22-25 </option>
<option value="3" selected="selected">26-29 </option>
<option value="4">30-35 </option>
<option value="5">Over 35 </option>
</select>
</body>这段代码怎么报错missing:before statement和show
is not defined
相关问答:
<form id="form1" runat="server">
<div>
<script type="text/javascript">
function oo(a){
document.getEleme ......
后台:
protected void form_ini2(string id)
{
//处理代码
}
前台:
<script language="javascript">
function DbClickEvent(a ......
对于JavaScript 来说要实现上面这三层含义,其实既简单又不简单。这个结论听起来很矛盾,但是你很快就会发现它是有道理的。下面将介绍几种JavaScript 中具体的实现继承的方法,并详细分析它们的利与弊。
......
三个数x,y,z 比大小..
var x,y,z,t;
if (x>y)
{t=x;x=y;y=t;} //交换x,y的值
if(x>z)
{t=z;z=x;x=t;}//交换x,z的值
if(y>z)
{t=y;y=z;z=t;}//交换z,y的值
这是 ......
JScript code:
<html>
<head>
<script type="text/javascript">
window.onload=function(){
var a = document.getElementsByTagName("a");
for(var i=0; i& ......