addMissiveNo.jsp复杂js判断--checkbox--json--全选--反选--取消

来源:互联网 发布:三级分销分成算法例子 编辑:程序博客网 时间:2024/05/29 15:09
[align=left][size=large]
<%@ page language="java"import="java.util.*,com.hxkj.commonbusiness.MissiveCombiz.MissiveTypeCombiz,com.hxkj.entity.*"%><%@ page contentType="text/html;charset=utf-8"%><%@ page import="java.util.*"%><%@page import="java.text.SimpleDateFormat"%><%@ include file="../common/taglibs.jsp"%><html:html><%String id = "-1";if (request.getAttribute("id") != null) {id = (String) request.getAttribute("id");}String path = request.getContextPath();//获取公文类别MissiveTypeCombiz misCom = new MissiveTypeCombiz();List<MissiveTypeBean> MissiveTypeBeans = misCom.getMissiveTypeByScope("-1");//全部,包含司发文和部门文pageContext.setAttribute("MissiveTypeBeans", MissiveTypeBeans);Date temp = new Date();SimpleDateFormat sdf = new SimpleDateFormat("yyyy");String tempStr = sdf.format(temp);%><head><link rel="stylesheet" href="<%=path%>/css/gcoa/css.css"><script language="Javascript" src="../../js/ortfunc.js"></script><script language="Javascript" src="../../js/ortfunct.js"></script><script language="Javascript" src="../../js/public.js"></script><!-- 选择部门时需要引入这两个js,从书中获取部门名称以及ID --><script type="text/javascript" src="<%=path%>/js/jquery.js"></script><script type="text/javascript" src="<%=path%>/js/user.js"></script><style type="text/css">.xian {border-bottom: 1px none;border-left: 1px none;border-top: 1px none;border-right: 1px none;text-align: left;font-size: 14px;background-color: ECF4FD;}</style><SCRIPT language="javascript">function saveMissiveNo(){var isTrue = true;var flag=0;var missiveType=document.getElementById("missiveType").value;var orgid=document.getElementById("orgid").value;var year=document.getElementById("year").value;var typeScope=document.getElementById("typeScope").value;//公司:不提示选择部门  if (typeScope == "") {    alert( "请选择所属类型!" );    document.forms[0].typeScope.focus();   isTrue=false;    }else if(document.forms[0].orgname.value==""&&typeScope!="0"){      alert('请选择部门');    document.forms[0].orgname.focus();   isTrue=false;    }else if(document.form.missiveType.length>0) {for (i = 0; i < document.form.missiveType.length; i++) {if (document.form.missiveType[i].checked==true) {flag=1;break;} else {flag=0; }}if(flag==0){alert('请至少选择一个公文类别');document.forms[0].mm.focus();isTrue=false;}  }  if(document.getElementById("news").checked==true){  if(document.getElementById("dealType").value == ""||document.getElementById("dealType").value ==null){alert('请选择处理类型');document.forms[0].dealType.focus();isTrue=false; }  }if(isTrue){ saveMissiveNoAjax(missiveType,orgid,year); document.forms[0].submit(); //新增成功之后重新返回addMissiveNo.jsp页面}}function saveMissiveNoAjax(x,y,z) { var xmlHttp; try    {   // Firefox, Opera 8.0+, Safari    xmlHttp=new XMLHttpRequest();    } catch (e)    {  // Internet Explorer   try      {      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      }   catch (e)      {      try         {         xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");         }      catch (e)         {         alert("您的浏览器不支持AJAX!");         return false;         }      }    }    xmlHttp.onreadystatechange=function()      {      if(xmlHttp.readyState==4)        {         document.myForm.time.value=xmlHttp.responseText;        }      }    xmlHttp.open("GET","<%=path%>/pages/MissiveNoManager/index.do?doaction=saveMissiveNo&missiveType="+x+"&orgid="+y+"&year="+z,true);//xz修改,针对ie8正文被锁bug    xmlHttp.send(null); } function  doChange(f){   if(f.value ==0)   {       document.getElementById("div").style.display="none";       document.getElementById("good").style.display="block";       document.getElementById("choice").style.display="block";   }else if(f.value ==1){      document.getElementById("div").style.display="block";      document.getElementById("good").style.display="block";      document.getElementById("good").value="";      document.getElementById("choice").style.display="block";   }   else{      document.getElementById("div").style.display ="block";      document.getElementById("good").style.display="none";      document.getElementById("good").value="";              } }function getMissiveType(){var typeScope=$('#typeScope').val();if(typeScope==""){ document.getElementById("choice").style.display="none";}$.ajax({type:"POST",dataType:"json",url:"<%=path%>/pages/CommonSession/index.do",data:"doaction=searchByMissiveTypeScope&typeScope="+typeScope,success:function(data){var len=data.length;$('#good').contents().remove();//for循环for(i=0;i<len;i++){$('#good').append("<input type='checkbox' name='missiveType' id='" + data[i].MISSIVE_TYPE_ID + " ' value='" + data[i].MISSIVE_TYPE_ID + "'/>" + data[i].NAME);}//for循环结束}});}function selfMissiveType(){if(document.getElementById("news").checked){     document.getElementById("div3").style.display="block";}if(document.getElementById("old").checked){     document.getElementById("div3").style.display="none";}}//全选、反选、取消//全选function selectAll() {for (i = 0; i < document.form.missiveType.length; i++) {if (!document.form.missiveType[i].checked) {document.form.missiveType[i].checked = true;}}}//反选function selectRerverse() {for (i = 0; i < document.form.missiveType.length; i++) {if (document.form.missiveType[i].checked) {document.form.missiveType[i].checked = false;} else {document.form.missiveType[i].checked = true;}}}//取消function cancelAll() {for (i = 0; i < document.form.missiveType.length; i++) {if (document.form.missiveType[i].checked) {document.form.missiveType[i].checked = false;}}}</SCRIPT></head><body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"><form name="form" method="post"action="<%=path%>/pages/missiveManage/addMissiveNo.jsp" target="_self"><input type="hidden" name="id" value="<%=id%>" /><table width="98%" border="0" align="center" cellpadding="0"cellspacing="0" bgcolor="E9ECF5"><tr><td height="26" colspan="2" valign="middle" class="font13"><div align="center">&nbsp;</div></td><td width="80%" height="26" valign="bottom" class="font13"><div align="right"><a href="javaScript:saveMissiveNo();" target="_self">保存</a>&nbsp;|&nbsp;<a href="<%=path%>/pages/missiveManage/MissiveNoManager.jsp"target="_parent">返回</a></div></td><td width="3%" valign="top" class="font13"><div align="right"><img src="<%=path%>/img/gcoa/tddir0101.gif" width="17" height="14"></div></td></tr></table><table width="98%" border="0" align="center" cellpadding="0"cellspacing="0" bgcolor="E9ECF5"><tr><td valign="top"><div align="center"><table width="95%" border="0" align="center" cellpadding="0"cellspacing="0" class="tablelsdi"><tr><td width="4%" background="<%=path%>/img/gcoa/tablelb01.gif"><img src="<%=path%>/img/gcoa/tablelb01-left.gif" width="21"height="22"></td><td width="82%" background="<%=path%>/img/gcoa/tablelb01.gif"class="font12w">新增公文字号</td><td width="14%" background="<%=path%>/img/gcoa/tablelb01.gif"><div align="right"><img src="<%=path%>/img/gcoa/tablelb01-right.gif" width="21"height="22"></div></td></tr></table><table width="95%" border="0" align="center" cellpadding="0"cellspacing="0" class="tablelb"><tr><td width="15%" height="30" bgcolor="E1EEFD" class="tablex"><div align="right">所属类型&nbsp;</div></td><td width="55%" height="30" bgcolor="E1EEFD" class="tableleft">&nbsp;<select name="typeScope" id="typeScope" style="width: 51%"onchange="doChange(this);getMissiveType()"><option value="" selected="selected">--请选择--</option><option value="0">公司</option><option value="1">部门</option></select></td></tr><tr id="div"><td height="30" bgcolor="ECF4FD" class="tablex"><div align="right">部门&nbsp;</div></td><td height="30" bgcolor="ECF4FD" class="tableleft">&nbsp;<input type="text" name="orgname" id="orgname"style="width: 40%" class="table" value="" readonly="readonly" /><input type="hidden" name="orgid" id="orgid" value="" /><input type="button" class="botton02" value="选择"onclick="selectorgAll();" /></td></tr><tr><td height="30" bgcolor="E1EEFD" class="tablex"><div align="right">是否新公文类型&nbsp;</div></td><td height="30" bgcolor="E1EEFD" class="tableleft">&nbsp;<input type="radio" name="like" id="news" value="1"onclick="selfMissiveType(this)" />是<span style="padding-left: 20px;"></span><input type="radio" name="like" id="old" value="0"onclick="selfMissiveType(this)" checked="checked" />否</td></tr><tr><td width="15%" height="30" bgcolor="ECF4FD" class="tablex"><div align="right" id="mm">公文类别&nbsp;</div></td><td width="55%" height="30" bgcolor="ECF4FD" class="tableleft">&nbsp;<div id="good" style="display: none"></div><div id="choice" style="display: none"><br/><font style="size: 5px;">可选操作:</font><spanstyle="padding-left: 15px;"></span><a href="javascript:selectAll()">全选</a><spanstyle="padding-left: 25px;"></span><a href="javascript:selectRerverse()">反选</a><spanstyle="padding-left: 25px;"></span><a href="javascript:cancelAll()">取消</a></div></td></tr><tr id="div3" style="display: none"><td width="15%" height="30" bgcolor="E1EEFD" class="tablex"><div align="right">处理类型&nbsp;</div></td><td width="55%" height="30" bgcolor="E1EEFD" class="tableleft">&nbsp;<select name="dealType" id="dealType" style="width: 51%"><option value="" selected="selected">--请选择--</option><option value="1">固定描述类型(年份)X号</option><option value="2">年份第X期(总第N期)</option><option value="3">部门+固定描述类型(年份)X号</option></select></td></tr><tr><td height="30" bgcolor="ECF4FD" class="tablex"><div align="right">年度&nbsp;</div></td><td height="30" bgcolor="ECF4FD" class="tableleft">&nbsp;<input type="text" name="year" id="year"value="<%=tempStr + 6%>" readonly="readonly" class="xian"></td></tr></table><br></div></td></tr></table></form></body></html:html>
[/size][/align]
0 0
原创粉丝点击