⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 modify.jsp

📁 “JSP数据库项目案例导航”一书从第一章到第十一章各章实例的源程序文件以及数据库文件。 注意: 1. 本书中的案例提供的数据库环境不同
💻 JSP
字号:
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<jsp:useBean id='db' scope='request' class='Base.DataBean.DefaultDataBean' />
<jsp:useBean id='dealstring' scope="page" class="com.util.DealString"/>
<html>
<head>
<link rel=stylesheet href="../index.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>角色配置</title>
</head>
<script language="javascript">
	function getChkValue(obj){
		/*
			obj				- the given checkbox
		*/
		var selitem = "";
		var x = 0;
		try{
			x = obj.length;
			for(i=0; i<obj.length; i++)			
				if(obj[i].checked)
					if(selitem==""){ 				
						selitem = obj[i].value;
					}
					else{
						selitem = selitem + "," + obj[i].value;
					}
		}
		finally{
			if (obj.checked)
				selitem = obj.value;
		}
		return selitem;		
	}
function getid(){
document.form1.right.value=getChkValue(document.form1.rightid);
document.form1.Submit;
}
</script>
<%
String [] rights=dealstring.splitStr(db.getAttributeStr("role.rights"),',');
%>
<%!
boolean IfHave(String param,String[] rights){
boolean  result=false;
for(int j=0;j<rights.length;j++){
if(Integer.parseInt(rights[j])==Integer.parseInt(param)){
result=true;
}
}
return result;
}
%>
<body>
<form name="form1" method="post" action="domodify.cgi">
<table width="100%" height="20"  border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
<table width="100%"  border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="40">&nbsp;</td>
    <td width="910"><table width="100%" height="20"  border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td height="20" class="title_s"><img src="../pics/login.gif" width=50>&nbsp;欢迎您>><%=(String)session.getAttribute("NAME")%> </td>
        </tr>
        <tr>
          <td height="5" bgcolor="#C8F8BA"></td>
        </tr>
        <tr>
          <td height="1" bgcolor="#2E990F"></td>
        </tr>
    </table></td>
    <td width="50">&nbsp;</td>
  </tr>
</table>
<table width="100%"  border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="40">&nbsp;</td>
    <td width="910">
      <table class="main_w" width="100%"  border="1" cellpadding="4" cellspacing="0" bordercolor="FFFFFF" bgcolor="E8FCE2">
        <tr bgcolor="#FFFFFF" class="title_s">
          <td height="20" colspan="2"><div align="center">角色权限修改
            <input name="id" type="hidden" id="id" value="<%= db.getAttributeStr("role.id")%>">
          </div>            
            <div align="center"></div></td>
        </tr>
        <tr class="title_s">
          <td width="45%" height="20"><div align="center" class="title_s">
            <div align="center">角色名称</div>
          </div></td>
          <td width="55%" height="20" class="main_w"><div align="center">
            <input name="name" type="text" id="name" value="<%= db.getAttributeStr("role.name")%>">
          </div></td>
          </tr>

        <tr>
          <td height="20"><div align="center" class="title_s">权限名称</div></td>
          <td height="20"><div align="center" class="title_s">权限显示</div></td>
          </tr>
		 <%
		 for(int i=0;i<db.getCount("right");i++){
		 %>
        <tr>
          <td height="20"><div align="center"><%= db.getAttributeStr("right.name",i)%>
            
          </div></td>
          <td height="20"><div align="center">
		  <%
		  if(IfHave(db.getAttributeStr("right.id",i),rights)){
		  %>
            <input name="rightid" type="checkbox" id="rightid" value="<%= db.getAttributeStr("right.id",i)%>" checked>
			<%
			}else{
			%>
			<input name="rightid" type="checkbox" id="rightid" value="<%= db.getAttributeStr("right.id",i)%>">
			<%
			}
			%>
          </div></td>
        </tr>
		<%
		}
		%>
        <tr>
          <td height="20" colspan="2"><div align="center">
            <input type="submit" onClick="getid()" name="Submit" value="提交" >
            <input type="reset" name="Submit2" value="重置">
			<input type="hidden" name="right" id ="right" value="" >
          		  </div></td>
          </tr>

    </table></td>
    <td width="50">&nbsp;</td>
  </tr>
</table>
</form>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -