baidu_29643173
baidu_29643173
采纳率3.8%
2015-08-11 04:41 浏览 2.0k

在表单的table中的每一个单元格加入俩个下拉菜单,求大神指导怎么写,跪求~

在表单的table中的每一个单元格加入俩个下拉菜单,求大神指导怎么写?下面有初步的jsp代码。我用的是SSH框架.有一个下拉菜单的值是动态的,是别的表内的属性。怎么把一个单元格里的两个数据分别确定

图片说明

 <%@page contentType="text/html;  charset=UTF-8" import="java.util.*" %>
<%@ page import="com.sysgrrj.module.ChangFangGouMai.valueobject.ChangFangGouMai" %>
<%@ page import="com.sysgrrj.common.TypeChange" %>
<%@  taglib prefix="s" uri="/struts-tags" %>
<html>
<head>
    <jsp:include page='/res/inc/inc.jsp' flush='true'/>
</head>
<body>
<s:form action="List" id="form1" theme="simple">
    <jsp:include page='/res/inc/inc_form_List.jsp' flush='true'/>
    <script type="text/javascript">
        function doAction(action) {
            if (confirm("是否确认保存?")) {

                document.getElementById("form1").action = "<%=request.getContextPath()%>/Module/ChangFangGouMai/List_save.action";
                document.getElementById("form1").submit();
                return true;
            }
            else {
                return false;
            }
        }




    </script>


    <div class="buttonDiv">


        <input type="button" class="button_style_save" onclick="doAction('')"/>
    </div>
    <div class="validatemsg">
        <s:actionerror/>
        <s:fielderror/>
        <s:actionmessage/>
    </div>

    <%


           //厂房购买
           List<ChangFangGouMai> changFangGouMaiList = (List<ChangFangGouMai>) request.getAttribute("changFangGouMaiList");


       %>





<table width="100%" class="listext" id="table1">
        <tr>
            <TH colspan="7" style="background:  #EBEBEB;height: 35px"> 厂房购买</TH>
        </tr>
    <TR>

       <TH width="30"> 序号</TH>
       <TH width="80">编号</TH>
       <TH>1</TH>
       <TH>2</TH>
       <TH>3</TH>
        <TH>4</TH>

       <%--<TH>trainingOrCompetitionID</TH>--%>
    </TR>

       <%   int i;
           int k;
           int j;
             String[] s;
              s=new String[6];
             for(j=1;j<7;j++){
                 String a[]={"第一年","第二年","第三年","第四年","第五年","第六年"};
        %>
      <TR>

          <TD><%=(j)%> </TD>
           <TD><%=(a[j-1])%> </TD>
          <%
             for(i=1;i<5;i++){
                 out.print("  <TD>");
                  String sr= "";
                 for(k=0;k<changFangGouMaiList.size();k++){
                     ChangFangGouMai changFangGouMai=changFangGouMaiList.get(k);
                     if(TypeChange.stringToInt(changFangGouMai.getNianDu())==j&&changFangGouMai.getBianHao()==i){
                         sr=changFangGouMai.getZuYongHuoGouMai();
                         break;
                     }
                 }
                 out.print("<input type=\"text\"   name=\""+j+"_"+i+"\" value=\"" + sr + "\"/>");
                 out.print("</TD>");

             }
          %>







       </TR>

      <%

          }

        %>
</TABLE>
    <s:hidden name="TrainingOrCompetitionID"/>
</s:form>
</body>
</html>

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

2条回答 默认 最新

  • ascdfwsfrfadfg inc1ud3 2015-08-11 04:54

    只能用ajax了,用js动态生成select标签,使用ajax返回来的数据填充option

    点赞 评论 复制链接分享
  • dcxy0 Q544471255 2015-08-11 07:22
     <%@page contentType="text/html;  charset=UTF-8" import="java.util.*" %>
    <%@ page import="com.sysgrrj.module.ChangFangGouMai.valueobject.ChangFangGouMai" %>
    <%@ page import="com.sysgrrj.common.TypeChange" %>
    <%@  taglib prefix="s" uri="/struts-tags" %>
    <html>
    <head>
        <jsp:include page='/res/inc/inc.jsp' flush='true'/>
    </head>
    <body>
    <s:form action="List" id="form1" theme="simple">
        <jsp:include page='/res/inc/inc_form_List.jsp' flush='true'/>
        <script type="text/javascript">
            function doAction(action) {
                if (confirm("是否确认保存?")) {
    
                    document.getElementById("form1").action = "<%=request.getContextPath()%>/Module/ChangFangGouMai/List_save.action";
                    document.getElementById("form1").submit();
                    return true;
                }
                else {
                    return false;
                }
            }
    
    
    
    
        </script>
    
    
        <div class="buttonDiv">
    
    
            <input type="button" class="button_style_save" onclick="doAction('')"/>
        </div>
        <div class="validatemsg">
            <s:actionerror/>
            <s:fielderror/>
            <s:actionmessage/>
        </div>
    
        <%
    
    
               //厂房购买
               List<ChangFangGouMai> changFangGouMaiList = (List<ChangFangGouMai>) request.getAttribute("changFangGouMaiList");
    
    
           %>
    
    
    
    
    
    <table width="100%" class="listext" id="table1">
            <tr>
                <TH colspan="7" style="background:  #EBEBEB;height: 35px"> 厂房购买</TH>
            </tr>
        <TR>
    
           <TH width="30"> 序号</TH>
           <TH width="80">编号</TH>
           <TH>1</TH>
           <TH>2</TH>
           <TH>3</TH>
            <TH>4</TH>
    
           <%--<TH>trainingOrCompetitionID</TH>--%>
        </TR>
    
           <%   int i;
               int k;
               int j;
                 String[] s;
                  s=new String[6];
                 for(j=1;j<7;j++){
                     String a[]={"第一年","第二年","第三年","第四年","第五年","第六年"};
            %>
          <TR>
    
              <TD><%=(j)%> </TD>
               <TD><%=(a[j-1])%> </TD>
              <%
                 for(i=1;i<5;i++){
                     out.print("  <TD>");
                      String sr= "";
                     for(k=0;k<changFangGouMaiList.size();k++){
                         ChangFangGouMai changFangGouMai=changFangGouMaiList.get(k);
                         if(TypeChange.stringToInt(changFangGouMai.getNianDu())==j&&changFangGouMai.getBianHao()==i){
                             sr=changFangGouMai.getZuYongHuoGouMai();
                             break;
                         }
                     }
                     out.print("<input type=\"text\"   name=\""+j+"_"+i+"\" value=\"" + sr + "\"/>");
                     out.print("</TD>");
    
                 }
              %>
    
              <!-- 新增部分  -->
    
              <td>
                <select>
                  <option value="1" <c:if test="${user.type eq '1'}">checked="checked"</c:if>  >选项1</option>
                  <option value="2" <c:if test="${user.type eq '2'}">checked="checked"</c:if>  >选项2</option>
                </select>
              </td>
               <!-- 新增部分END  -->
               <!--
               返回一个列表项,通过EL表达式判断值是否对应当前选项,然后进行设置即可.
               -->
    
    
    
    
    
           </TR>
    
          <%
    
              }
    
            %>
    </TABLE>
        <s:hidden name="TrainingOrCompetitionID"/>
    </s:form>
    </body>
    </html>
    
    点赞 评论 复制链接分享

相关推荐