一段有用的的javascript

本文展示了一个使用Struts框架实现的部门管理页面代码示例。该页面支持部门信息的增删改查功能,并提供了部门树的刷新选项。通过JavaScript实现了部分交互功能,如确认删除对话框等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<%@ page contentType="text/html;charset=gb2312"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="/tags/webui" prefix="webui"%>
<%@ taglib uri="/tags/c" prefix="c"%>
<%
String contextPath = request.getContextPath();;
%>
<html>
<head>
<title>系统功能列表</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="<%=contextPath%>/styles/global.css"
type="text/css">
<script language="JavaScript">
<!--
function doCreate();{
document.formList.action="<%=contextPath%>/admin/sys/Dept_add.jsp";
document.formList.submit();;
}
function doUpdate();{
if(isSelect(););{
document.formList.action="<%=contextPath%>/admin/sys/Dept_edit.jsp";
document.formList.submit();;
}
}
function doDelete();{

if(isSelect(););{
var ok=null;
ok = confirm("确实要删除吗?");;
ok = confirmDeletePost();;
if (ok!=true);{
return false;
}else{
document.formList.action="<%=contextPath%>/admin/deleteDept.do";
document.formList.submit();;
}
}
}
function confirmDeletePost();{
var radioGrp = document.formList.deptId;
var radioValue = null;
var i = 0;
if(radioGrp.length);{
for (i = 0; i< radioGrp.length; i++); {
if (radioGrp[i].checked); {
radioValue = document.formList.deptId[i].value;
break;
}
}
}
var hasPostGrp = document.formList.hasPost;
var hasPostValue = hasPostGrp[i].value;
var ok=null;
if(hasPostValue=true);
{
ok= confirm("部门里面已经建立了职位,确实要删除吗?");;
}
return ok;
}


function isSelect();{
var radioGrp = document.formList.deptId;
if(radioGrp.length);{
for (var i = 0; i< radioGrp.length; i++); {
if (radioGrp[i].checked); {
return true;
}
}
}else if(radioGrp.checked);{
return true;
}
alert("在操作前请先择数据!");;
return false;
}
-->
</script>
</head>
<body bgcolor="#FFFFFF" oncontextmenu="self.event.returnValue=false;"
onmousemove="if(event.ctrlKey); document.all.aaaa.focus();"
onselectstart="return false">
<div align="center"><html:errors />
<form name="formList" method="post">

<table width="99%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="25" align="center">部门列表</td>
</tr>
<tr>
<td align="center">
<table width="500" class="pageList" align="center">
<tr class="pageTh">
<th width="40" align="center">序号</th>
<th width="28%" align="center">名称</th>
<th width="28%" align="center">当前是否有职务</th>
</tr>
<c:forEach var="Dept" items="${PageList}">
<tr class="pageBody" onMouseOver="this.bgColor='#e7e7e7';"
onMouseOut="this.bgColor='#f9f9f9';">
<td width="18%" align="center" nowrap><c:choose>
<c:when test="${Dept.deptId==PageList[0].deptId}">
<input type="radio" name="deptId"
value="<c:out value="${Dept.deptId}"/>" checked="true">
</c:when>
<c:otherwise>
<input type="radio" name="deptId"
value="<c:out value="${Dept.deptId}"/>">
</c:otherwise>
</c:choose><c:out value="${Dept.code}" /></td>
<td><c:out value="${Dept.name}" /> <input type="hidden"
name="hasPost" value="<c:out value="${Dept.hasPost}" />" /></td>
<c:choose>
<c:when test="${Dept.hasPost}">
<td width="28%" align="center">有</td>
</c:when>
<c:otherwise>
<td width="28%" align="center">无</td>
</c:otherwise>
</c:choose>
</tr>
</c:forEach>
<tr class="pageTf">
<td colspan="3" align="center"><webui:gotoPage name="PageList"
form="true" formName="formList" /></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center"><a
href="<%=contextPath%>/admin/sys/Dept_add.jsp?parentId=<c:out value="${parentId}" />&pageNo=<c:out value="${pageNo}" />"><img
src="<%=contextPath%>/images/icons/create.gif" width="16" height="16"
border="0" alt="添加">增加下一级部门</a> <a
href="<%=contextPath%>/admin/sys/Dept_tree.jsp" target="show"><img
src="<%=contextPath%>/images/icons/refresh.gif" width="16"
height="16" border="0" alt="刷新">刷新部门树 </a><a href="#"
onClick="doDelete();"><img name="iconDelete"
src="<%=contextPath%>/images/icons/delete.gif" width="16" height="16"
border="0" alt="删除" onClick="doDelete();">删除</a>& <a href="#"
onClick="doUpdate();"><img name="iconUpdate"
src="<%=contextPath%>/images/icons/update.gif" width="16" height="16"
border="0" alt="修改" onClick="doUpdate();">修改</a></td>
</tr>
</table>
</form>
</div>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值