msgaddmsg.jsp
来自「java jsp教程」· JSP 代码 · 共 343 行
JSP
343 行
<!--\webapps\jspmsgnote\msgaddmsg.jsp by wuwf-->
<%@ page contentType="text/html; charset=GBK" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.List" %>
<%@ page import="com.icss.cnpc.msgnote.vo.*"%>
<%@ page import="com.icss.resourceone.sdk.configuration.ConfigManager"%>
<%@ page import="com.icss.resourceone.sdk.configuration.Parameter"%>
<%@ page import="com.icss.cnpc.msgnote.util.CommonUtil"%>
<%@ page import="com.icss.cnpc.msgnote.util.*"%>
<%
response.setHeader("Pragma", "No-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
%>
<%
int attachnum = CommonUtil.getAttachNum();
int number = attachnum;//欠合理
String islarge = request.getParameter("islarge");
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=GBK">
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/style.css" type="text/css">
<script language="JavaScript" src="<%=request.getContextPath()%>/include/common.js"></script>
<script language="JavaScript">
function opernNewWind(){
document.MsgForm.action="<%=request.getContextPath()%>/Msg_SelectOrg.jsp";
document.MsgForm.submit();
}
<!---------------------->
function _CheckFormSave()
{
if(document.MsgForm.msg_title.value==""){
alert("请填写消息标题!");
return false;
document.MsgForm.msg_title.focus;
}
if(document.MsgForm.msg_body.value==""){
alert("请填写消息内容!");
document.MsgForm.msg_body.focus;
return false;
}
return true;
}
<!---------------------->
function _CheckForm()
{
if(document.MsgForm.msg_title.value==""){
alert("请填写消息标题!");
return false;
document.MsgForm.msg_title.focus;
}
if(document.MsgForm.msg_body.value==""){
alert("请填写消息内容!");
document.MsgForm.msg_body.focus;
return false;
}
if(document.MsgForm.receiverCode.value==""){
alert("请选择接收人!");
return false;
}
return true;
}
<!---------------------->
function _save()
{
if(!_CheckFormSave()){
return false;
}
var sform = document.MsgForm;
var filesnum=0;
for(var ii=0;ii<sform.length;ii++){
if(sform.elements[ii].type == "file")
filesnum++;
}
document.MsgForm.filesnumber.value = filesnum;
document.MsgForm.operate.value = "save";
var receiverName=document.MsgForm.receiverName.value;
document.MsgForm.action="<%=request.getContextPath()%>/servlet/MsgAddServlet?receiverName="+receiverName;
document.MsgForm.submit();
}
<!---------------------->
function _send()
{
if(!_CheckForm())
{return false;}
var sform = document.MsgForm;
var filesnum=0;
for(var ii=0;ii<sform.length;ii++)
{
if(sform.elements[ii].type == "file")
filesnum++;
}
document.MsgForm.filesnumber.value = filesnum;
document.MsgForm.operate.value = "send";
document.MsgForm.action="<%=request.getContextPath()%>/servlet/MsgAddServlet";
document.MsgForm.submit();
}
<!---------------------->
function _Reset()
{
document.MsgForm.msg_title.value="";
document.MsgForm.msg_body.value="";
document.MsgForm.receiverCode.value = "";
document.MsgForm.receiverName.value = "";
document.MsgForm.msg_title.focus;
}
<!---------------------->
function _BackTo()
{
history.back();
}
<!---------------------->
function _getAddrBook(){
var a = new Object();
a.titleDesc = "从地址簿选择";
a.receiverCode = document.MsgForm.receiverCode.value;
a.receiverName = document.MsgForm.receiverName.value;
var b =showModalDialog("<%=request.getContextPath()%>/servlet/ShowAddrBookServlet",a,"dialogWidth:800px;dialogHeight:650px;status:0;");
if (b != null)
{
document.MsgForm.receiverCode.value = b.receiverCode;
document.MsgForm.receiverName.value = b.receiverName;
}
}
<!---------------------->
var attachnum;
<!---------------------->
function fileChange(){
attachnum = document.MsgForm.attachnum.value;
for(var m = 0;m < attachnum; m++)
{
fileselect = eval("document.all.file"+m+".style");
fileselect.display = "none";
}
document.all.display1.style.display = "none";
}
<!---------------------->
var curnum = 0;
var allnum = 0;
<!---------------------->
function addatt(src)
{
if(allnum > (attachnum-1) || curnum > (attachnum-1))
{
alert("附件最多不能超过"+attachnum+"个!");
document.all.display1.style.display = "none";
document.all.display.style.display = "none";
return false;
}
<!---->
//var totalattnum = <%=attachnum%>;
//alert("totalattnum---->"+totalattnum);
//for(var i = 0;i < totalattnum;i ++){
//checkfile = eval("document.all.file"+i+".style");
//if(checkfile.display = "none"){
//curfile = eval("document.all.file"+i+".style");
//}
//break;
//}
//alert(curfile);
<!---->
/*
curfile = eval("document.all.file"+curnum+".style");
curfile.display = "";
curnum ++;
allnum ++;
if(allnum < 0)
{
document.all.display1.style.display = "none";
document.all.display.style.display = "";
}
else
{
if(allnum > (attachnum-1) || curnum > (attachnum-1))
{
document.all.display1.style.display = "none";
document.all.display.style.display = "none";
document.all.display2.style.display = "none";
}
else
{
document.all.display.style.display = "none";
document.all.display1.style.display = "";
}
}
*/
maxNum = <%=attachnum%>;
for(var i=0; i<maxNum; i++)
{
var obj = document.all["file" + i];
if(obj != null && obj.style)
{
if(obj.style.display && obj.style.display != "block")
{
obj.style.display = "block";
break;
}
}
}
curnum ++;
allnum ++;
if(i >= maxNum - 1)
{
src.parentElement.parentElement.style.display = "none";
}
}
<!---------------------->
var delnum="";
<!---------------------->
function delatt(flag,j)
{
curfile = eval("document.all."+flag+".style");
var fileTD = document.getElementById("fileTD" + j);
if(fileTD)
{
fileTD.innerHTML = "<input name=\"uploadfile" + j + "\" type=\"file\">";
}
curfile.value = "";
curfile.display = "none";
allnum --;
curnum --;
delnum=","+j+delnum;
document.MsgForm.deletenum.value = delnum;
if(allnum < 1)
{
//document.all.display1.style.display = "none";
document.all.display.style.display = "";
}
else
{
if(allnum > (attachnum-1) || curnum > (attachnum-1))
{
//document.all.display1.style.display = "none";
document.all.display.style.display = "none";
document.all.display2.style.display = "none";
}
else
{
//alert("Now you in the else path of the delatt function");
document.all.display.style.display = "";
//document.all.display1.style.display = "";
}
}
}
<!---------------------->
function alertUser()
{}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="10" onLoad="javascript:alertUser()" background="<%=request.getContextPath()%>/images/grid.gif">
<form Name="MsgForm" method="Post" action="" enctype="multipart/form-data">
<input type="hidden" name="operate" value="">
<input type="hidden" name="filesnumber" value="">
<input type="hidden" name="receiverCode" value="">
<input type="hidden" name="attachnum" value="<%=number%>">
<input type="hidden" name="deletenum">
<br>
<table width="70%" border="0" align="center">
<tr>
<td>
<table width="100%" border="0" align="center" cellspacing="1" cellpadding="2" align="center" bordercolordark="#DFDFFF" bordercolorlight="#003366" bgcolor="#6699CC">
<tr>
<td height="24" colspan="2" align="center" bgcolor="#a6d0f2">输入您的通知内容</td>
</tr>
<tr bgcolor="#EEF4FF">
<td width="19%" height="25" align="right" >接收单位/个人</td>
<td align="left" width="81%" ><input type="text" name="receiverName" value="" size="50" readonly>
<img src="<%=request.getContextPath()%>/images/select.gif" style="cursor: hand" onClick="_getAddrBook()">
</td>
</tr>
<tr bgcolor="#EEF4FF">
<td width="19%" height="25" align="right">标题</td>
<td align="left" valign="top"><input name="msg_title" type="text" class="txt1" size="50" value="" maxlength="64">*</td>
</tr>
<tr bgcolor="#EEF4FF">
<td width="19%" height="25">
<div align="right">重要程度</div></td>
<td align="left" valign="top">
<select name="impselect">
<option value="1" >一般</option>
<option value="5" >紧急</option>
</select>
</td>
</tr>
<tr bgcolor="#EEF4FF">
<td width="19%" height="176"><p align="right" class="style1">内</p><p align="right" class="style1">容</p></td>
<td align="left" valign="top"><textarea name="msg_body" cols="65" rows="12" maxlength="999"></textarea></td>
</tr>
<%
for(int j = 0; j < attachnum; j++)
{
%>
<tr id="file<%=j%>" style="display:none;" bgcolor="#EEF4FF">
<td align="right">附件</td>
<td align="center">
<table border="0" width="100%">
<tr>
<td id="fileTD<%=j%>"><input name="uploadfile<%=j%>" type="file"></td>
<td align="left">
<img src="<%=request.getContextPath()%>/images/delete.gif" style="cursor: hand" onclick="javascript:delatt('file<%=j%>','<%=j%>')"></td>
</tr>
</table>
</td>
</tr>
<%
}
%>
<tr id="display" bgcolor="#EEF4FF">
<td height="27" colspan="2" align="center">
<img src="<%=request.getContextPath()%>/images/buttons/attachmentadd.gif" style="cursor: hand" onClick="addatt(this)">
</td>
</tr>
<tr valign="bottom" id="display2" bgcolor="#EEF4FF">
<td height="27" colspan="2" align="center"><font color="#0000FF">最多能添加<%=String.valueOf(CommonUtil.getAttachNum())%>个附件,每个附件最大为<%=String.valueOf(CommonUtil.getAttachSize())%>M</font></td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<center>
<img style="CURSOR:hand" onClick="javascript:_save()" src="<%=request.getContextPath()%>/images/save.gif" border=0></td>
<img style="CURSOR:hand" onClick="javascript:_send()" src="<%=request.getContextPath()%>/images/send.gif" border=0></td>
<img style="CURSOR:hand" onClick="javascript:_Reset()" src="<%=request.getContextPath()%>/images/reset.gif" border=0></td>
<img style="CURSOR:hand" onClick='window.history.go(-1)' src="<%=request.getContextPath()%>/images/return.gif" border=0></td>
</center>
</form>
<script>
//fileChange();
</script>
</body>
</html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?