一. 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() 的左括号匹配
博客展示了JavaScript函数代码,包括全选、计数、删除、编辑、查询等功能函数,还给出了在JSP上调用这些函数的示例。不过在调用时,doQuery()函数无法触发,且代码存在括号匹配问题。

992

被折叠的 条评论
为什么被折叠?



