动态表格行列增删 处理JS和JAVA代码交互 功能强大

来源:互联网 发布:淘宝网被限制登录 编辑:程序博客网 时间:2024/04/29 07:03
 

<%@ page contentType="text/html;charset=GBK"%>
<%@ include file="/mdm/include/jsp/stmadc_header.jsp" %>
<%@ page import="javax.servlet.http.HttpSession"%>
<%@ page import="java.util.HashMap"%>
<%@ page import="java.util.List"%>
<%@ page import="com.icss.mdm.vo.MdmBasicRuleVO"%>
<%
    String combineRuleId = (String)request.getAttribute("combineRuleId");
    String combineRuleName = (String)request.getAttribute("combineRuleName");
    List basicRuleList = (List)request.getAttribute("basicRuleList");
%>
<!-- 内容区域 begin -->
<link href="<%=request.getContextPath()%>/mdm/css/template.css" rel="stylesheet" type="text/css">
<SCRIPT LANGUAGE="JavaScript" src="<%= contextPath %>/mdm/include/js/jcommon.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript">


function add(){
    var rowOneTemp = document.getElementById("rowOne");
    var colLength = rowOne.cells.length;
    if(colLength>7){
        alert("内容不能超过6个");
        return;
    }
    var cellOne = rowOneTemp.insertCell(colLength - 1);
    cellOne.setAttribute("align","center");
    cellOne.innerHTML = "内容" + (colLength - 1);
    var rowTwoTemp = document.getElementById("rowTwo");
    var cellTwo = rowTwoTemp.insertCell(colLength - 1);
    cellTwo.innerHTML = " <select name=\"" + (colLength - 1) + " \" style=\"width:72\"  "
+ "onFocus=\"this.style.width=\'auto\' \" "
+ "onblur=\"this.style.width=\'70px\'\" "
+ "    onchange=\"setLength(this)\"    > "
   
    <%
              for(int i=0;i<basicRuleList.size();i++){
              MdmBasicRuleVO temp = (MdmBasicRuleVO)basicRuleList.get(i);
          %>
            + " <OPTION value='<%=temp.getId()%>'><%=temp.getRuleName() %></OPTION> "
             <% }%>
    +" </select> " ;
   
    var rowThreeTemp = document.getElementById("rowThree");
    var cellThree = rowThreeTemp.insertCell(colLength - 1);
    cellThree.setAttribute("id","length" + (colLength - 1) );
   
}

function minus(){
    var rowOneTemp = document.getElementById("rowOne");
    var colLength = rowOne.cells.length;
    if(colLength<7){
        alert("内容至少为4个!");
        return;
    }
    var cellOne = rowOneTemp.deleteCell(colLength - 2);
    var rowTwoTemp = document.getElementById("rowTwo");
    var cellTwo = rowTwoTemp.deleteCell(colLength - 2);
    var rowThreeTemp = document.getElementById("rowThree");
    var cellThree = rowThreeTemp.deleteCell(colLength - 2);
}

function setLength(obj){

    var cellName = "length" + obj.name;
    var cellInRowThree = document.getElementById(cellName);
    if(cellInRowThree == null){
 
        var rowThreeTemp = document.getElementById("rowThree");
        cellInRowThree  = rowThreeTemp.cells[obj.name];
    }
    cellInRowThree.setAttribute("align","center");
    var temp = document.getElementById(obj.value);
    cellInRowThree.innerHTML = "" + temp.name;
}

function next(){


}

</SCRIPT>
<form method="post" name="frmSub">
<table align="left" width="100%" border="0" cellpadding="0" cellspacing="0" height="100%" background="<%= contextPath%>/mdm/images/main_bg.gif">
  <tr><td height="12">&nbsp;</td></tr>
  <tr>
    <td align="left" colspan="2"  valign="top" height="20">
      <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr>
          <td>
            &nbsp;<img src="<%= contextPath%>/mdm/images/main_r2_c1.jpg" width="11" height="11">
            <b>当前位置:</b> 信息资源管理系统 -&gt;  生成规则 -&gt; 新建组合规则
          </td>
          <!--
          <TD width="16">
            <DIV align=right><IMG height=16  src="<%= contextPath%>/mdm/images/wenhao.jpg"  width=16></DIV>
          </TD>
          <td width="60">
            <a href="#" onclick="window.open('<%= contextPath %>/mdm/html/help/rule/generate/CodeGenerateRuleList.htm','','width='+(screen.width/2)+',height='+(screen.availHeight/2)+',left='+(screen.width/4)+',top='+(screen.availHeight/4));" style='text-decoration:none' ><font color="FF6D00">使用帮助</font></a>
          </td>
        -->
        </tr>
      </table>
    </td>
  </tr>
  <tr>
   <td align="center" valign="top" background="<%= contextPath %>/mdm/images/right-bj.gif">
        <table width="100%" border="0" cellpadding="3" cellspacing="1">
          <tr>
            <td>
              <table height=300 cellSpacing=1 cellPadding=3 width="100%"  border=0>
                <tr align=center bgColor=#efefef>
                  <td valign="top" bgcolor="#FFFFFF">
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td width="31%" height="293" valign="top"><img src="<%= contextPath %>/mdm/images/left5.gif"></td>
                        <td width="69%" valign="top">
                          <table width="80%" border="0" cellspacing="0" cellpadding="0" align="center">
                            <tr><td></td></tr>
                            <tr>
                              <td height="370" align="center"><span class="atitle_font">定义组合规则详细内容
                              </span><br>
                                   <table border="0" align="left" cellpadding="0" cellspacing="0">
         <tr>
           <td valign="bottom" background="<%=request.getContextPath()%>/mdm/images/border_2.gif"><img src="<%=request.getContextPath()%>/mdm/images/border_1.gif" width="11" height="13"></td>
           <td background="<%=request.getContextPath()%>/mdm/images/border_2.gif"></td>
           <td valign="bottom"><img src="<%=request.getContextPath()%>/mdm/images/border_6.gif" width="10" height="13"></td>
         </tr>
         <tr>
           <td background="<%=request.getContextPath()%>/mdm/images/border_3.gif"></td>
           <td width="100%">
       
                                <table id="tableRule" width="100%" border=0 align="center" cellpadding=0 cellspacing=0 >
                                <tr id="rowOne">
                                <td align="left">组合规则:</td>
                                <td align="center">内容1</td>
                                <td align="center">内容2</td>
                                <td align="center">内容3</td>
                                <td align="center">内容4</td>
                                <td align="center">内容5</td>
                                <td align="center"><input type="button" name="button1" value="+" onclick="add()"></td>
                               
                                </tr>
                               
                                <tr id="rowTwo">
                                <td></td>
                                <td align="center">
                                <select name="1" style="width:72px" onFocus="this.style.width='auto'" onblur="this.style.width='70px'"
                                onchange="setLength(this)"
                                > 
                               
                                <%
                                for(int i=0;i<basicRuleList.size();i++){
                                MdmBasicRuleVO temp = (MdmBasicRuleVO)basicRuleList.get(i);
                                %>
                                <OPTION value="<%=temp.getId()%>"><%=temp.getRuleName() %></OPTION>
                                <% }%>
 
                                </select>
                                </td>
                               
                                <td align="center">
                               <select name="2" style="width:72px" onFocus="this.style.width='auto'" onblur="this.style.width='70px'" onchange="setLength(this)"> 
                               
                                <%
                                for(int i=0;i<basicRuleList.size();i++){
                                MdmBasicRuleVO temp = (MdmBasicRuleVO)basicRuleList.get(i);
                                %>
                                <OPTION value="<%=temp.getId()%>"><%=temp.getRuleName() %></OPTION>
                                <% }%>
 
                                </select>
                                </td>
                                                           
                                <td align="center">
                                <select name="3" style="width:72px" onFocus="this.style.width='auto'" onblur="this.style.width='70px'" onchange="setLength(this)"> 
                               
                                <%
                                for(int i=0;i<basicRuleList.size();i++){
                                MdmBasicRuleVO temp = (MdmBasicRuleVO)basicRuleList.get(i);
                                %>
                                <OPTION value="<%=temp.getId()%>"><%=temp.getRuleName() %></OPTION>
                                <% }%>
 
                                </select>
                                </td>
                                <td align="center">
                                <select name="4" style="width:72px" onFocus="this.style.width='auto'" onblur="this.style.width='70px'" onchange="setLength(this)"> 
                               
                                <%
                                for(int i=0;i<basicRuleList.size();i++){
                                MdmBasicRuleVO temp = (MdmBasicRuleVO)basicRuleList.get(i);
                                %>
                                <OPTION value="<%=temp.getId()%>"><%=temp.getRuleName() %></OPTION>
                                <% }%>
 
                                </select>
                                </td>
                               
                                <td align="center">
                                <select name="5" style="width:72px" onFocus="this.style.width='auto'" onblur="this.style.width='70px'" onchange="setLength(this)">                           
                                <%
                                for(int i=0;i<basicRuleList.size();i++){
                                MdmBasicRuleVO temp = (MdmBasicRuleVO)basicRuleList.get(i);
                                %>
                                <OPTION value="<%=temp.getId()%>"><%=temp.getRuleName() %></OPTION>
                                <% }%>
 
                                </select>
                                </td>
                               
                                <td align="center"><input type="button" name="button2" value="-" onclick="minus()"></td>
                               
                                </tr>
                               
                               <tr id="rowThree">
                              
                               <td align="left">长度:
                              
                               <%
                               for(int i=0;i<basicRuleList.size();i++){
                                MdmBasicRuleVO temp = (MdmBasicRuleVO)basicRuleList.get(i);
                               
                               %>
                               <input type="hidden" id="<%= temp.getId()%>" name="<%= temp.getLength()%>">                              
                               <%}%>
                              
                              
                               </td>
                               <td id="length1"></td>
                               <td id="length2"></td>
                               <td id="length3"></td>
                               <td id="length4"></td>
                               <td id="length5"></td>
                               <td id="other"></td>
                               </tr>
                                </table>
                                    
                                </td>
                              </tr>
                              <tr style="height:30px">
                              <td>&nbsp;</td>
                              </tr>
                              <tr>
                               <td colspan=6 align="center">
                                    <input type="button" name="button1" onclick="next()" value="下一步" class="button"  style="cursor:hand">
                                    </td>
                                    </tr>
                            </table>
                          </td>
                        </tr>
                      </table>
                    </td>
                  </tr>
                </table>
              </td>
            </tr>
          </table>
        </td>
      </tr>
    </table>
  </td>
</tr>
</table>
 </form>
<!-- 内容区域 end -->
<!-- Tail begin -->
<%@ include file="/mdm/include/jsp/stmadc_tail.jsp" %>
<!-- Tail end -->

原创粉丝点击