JavaScript代码的括号匹配问题

来源:互联网 发布:数码暴龙网络侦探下载 编辑:程序博客网 时间:2024/04/25 17:27

一. javascript函数的代码

<script language="JavaScript">
function changeSelectAll(name,form){
 for (var i=0;i<form.elements.length;i++){
  var e = form.elements[i];
  if (e.name == name){
   e.checked = form.selectall.checked;
  }
    }
}

function countChecked(name,form){
 num=0;
 for (var i=0;i<form.elements.length;i++){
  var e = form.elements[i];
  if (e.name == name){
   if(e.checked == true){
    num++
   }
  }
                //if(num !=0) alert("select!");
    }
 return num;
}

function doRemove(form){
 name='typeIds';
 if(countChecked(name,form)==0){
  alert("请选中要删除的信息!");
  return false;
 }
 if(confirm("你将永久删除所选信息。/n你确定要删除吗?")){
  form.submit();
  return true;
 }
}

function doEdit(form){
 name='typeIds';
 num=countChecked(name,form);
 if(num<1){
  alert("请选中要修改的信息!");
  return false;
 }
 if(num>1){
  alert("一次只能修改一条记录!");
  return false;
 }
 for (var i=0;i<form.elements.length;i++){
  var e = form.elements[i];
  if (e.name == name){
   if(e.checked == true){
                                //alert("befor");
    window.location.href='roomtypeedit.do?typeid='+e.value;
                                //alert("after");
    return true;
   }
  }
    }

function doQuery(form){
     //form.curPage.value=1;
     form.action='roomtypequery.do'
     form.submit();
     return true;
}

}  //出错的地方!!!!!!!!!!!!!!!!
</script>

二. jsp上的调用

<a href="#" onclick="return doEdit(document.roomTypeListForm);"><img border="0" src="../images/behind_23.jpg" width="54" height="29"></a>
 <a href="#" onclick="return doRemove(document.roomTypeListForm);"><img border="0" src="../images/behind_25.jpg" width="60" height="29"></a>
 <a href="#" onclick="return doQuery(document.roomTypeListForm);"><img border="0" src="../images/behind_25.jpg" width="60" height="29"></a>

//结果不能触发函数doQuery();
//修改:颜色为蓝色的右括号应该与函数doEdit() 的左括号匹配

原创粉丝点击