jsp jquery怎么在同一个页面写两个 form 同时向数据库的两个表插入数据

wenwen1 发布于 2012/09/03 19:02
阅读 1K+
收藏 0
<%@ page language="java" import="java.util.*,java.sql.*" pageEncoding="UTF-8"%>
<jsp:useBean id="dbConn" class="pack_convert.DBConnXmgl"/>
<jsp:useBean id="systemRelated" class="net.gvsun.database.SystemRelated"/>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <title>立项申请</title>
<style type="text/css">
        label{
            width:200px;
            display:block;
        }
        td{
         width:300px;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="../../jquery/themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="../../jquery/themes/icon.css">
    <script type="text/javascript" src="../../jquery/js/jquery-1.7.1.min.js"></script>
    <script type="text/javascript" src="../../jquery/js/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="../../jquery/locale/easyui-lang-zh_CN.js"></script>
        <script>
//--------------------------更改日期格式 ------------------------------------------   
     $(document).ready(function(){
       $("#xmyjwcsj").datebox({
        formatter:formatD
         });
    $("#Setup_Date").datebox({
    formatter:formatD
     });
  })
  function formatD(date){
   return date.getFullYear()+"-"+date.getMonth()+"-"+date.getDay();
  }
 //------------------------------结束 -----------------------------
</script>
<script>
    $(document).ready(function(){
        getSource();//得到项目来源
        getSfwd();//得到所服务的国民经济行业
        getHdlx();//得到活动类型
        getZgxl();//得到最高学历
        getZgxw();//得到最高学位
        getRole();//得到负责人角色 
    });
//------------------------------项目来源下拉框 -----------------------------
    function getSource()
    {
         $.getJSON("../json/source.json", function (data){
                for (var i = 0; i < data.length; i++) {
                    $("#Source").append($("<option value=\""+data[i].Source_From+"\">"+data[i].Source_From+"</option>"));
                }
        });
    }   
//------------------------------结束 -----------------------------
//------------------------------活动类型下拉框 -----------------------------
    function getHdlx()
    {
         $.getJSON("../json/hdlx.json", function (data){
                for (var i = 0; i < data.length; i++) {
                    $("#hdlx").append($("<option value=\""+data[i].hdlx+"\">"+data[i].hdlx+"</option>"));
                }
        });
    }   
//------------------------------结束 -----------------------------
//------------------------------行业下拉框 -----------------------------
    function getSfwd()
    {
         $.getJSON("../json/sfwd.json", function (data){
                for (var i = 0; i < data.length; i++) {
                    $("#sfwd").append($("<option value=\""+data[i].sfwd+"\">"+data[i].sfwd+"</option>"));
                }
        });
    }   
//------------------------------结束 -----------------------------
//------------------------------最高学历下拉框 -----------------------------
    function getZgxl()
    {
         $.getJSON("../json/zgxl.json", function (data){
                for (var i = 0; i < data.length; i++) {
                    $("#zgxl").append($("<option value=\""+data[i].zgxl+"\">"+data[i].zgxl+"</option>"));
                }
        });
    }   
//------------------------------结束 -----------------------------
//------------------------------最高学位下拉框-----------------------------
    function getZgxw()
    {
         $.getJSON("../json/zgxw.json", function (data){
                for (var i = 0; i < data.length; i++) {
                    $("#zgxw").append($("<option value=\""+data[i].zgxw+"\">"+data[i].zgxw+"</option>"));
                }
        });
    }   
//------------------------------结束 -----------------------------
//------------------------------负责人角色下拉框-----------------------------
    function getRole()
    {
         $.getJSON("../json/role.json", function (data){
                for (var i = 0; i < data.length; i++) {
                    $("#role").append($("<option value=\""+data[i].Role_ID+"\">"+data[i].Role+"</option>"));
                }
        });
    }   
//------------------------------结束 -----------------------------

</script>
  </head>
  <%
String datenow = systemRelated.getDateNow();
request.setCharacterEncoding("utf-8");//处理乱码
%>
  <body> 
<form id="xm" name="form1" method="post" action="proApplicationSub.jsp">
<fieldset>
        <legend>项目基本信息(带*号为必填项)</legend>
          <table id="one">
           <tr><td><label for="Project_Attribute">项目性质*:</label></td>
               <td><input class="easyui-validatebox" type="text" name="Project_Attribute" required="true"></input></td>
               <td align="right"><label for="Project_Name">项目名称*:</label></td>
               <td><input class="easyui-validatebox" type="text" name="Project_Name" required="true"></input></td></tr>
           <tr><td><label for="xklym">学科领域码*:</label></td>
               <td><input class="easyui-validatebox" type="text"  name="xklym" required="true"></input></td>
               <td align="right"><label for="Ext_Name">学科领域*:</label></td>
               <td><input class="easyui-validatebox" type="text" id="Ext_Name" name="Ext_Name" required="true"></input></td></tr>
           <tr><td><label for="Project_Requirement">项目委托单位*:</label></td>
               <td><input class="easyui-validatebox" type="text" name="Project_Requirement" required="true"></input></td>
               <td align="right"><label for="Source_From">项目来源*:</label></td>
               <td><select  id="Source" name="Source_From"><option>----请选择一种项目来源----</option></select></td></tr>
           <tr><td><label for="Setup_Date">项目开始时间*:</label></td>
               <td><input class="easyui-datebox" type="text" name="Setup_Date" required="true" ></input></td>
               <td align="right"><label for="End_Date">登记时间*:</label></td>
               <td><input class="easyui-datebox" type="text" name="Setup_Date" value='<%=datenow %>' disabled></input></tr>
           <tr><td><label for="xmyjwcsj">项目预计完成时间*:</label></td>
               <td><input class="easyui-datebox" type="text" name="xmyjwcsj" required="true" ></input></td>
               <td align="right"><label for="pzwcsj">批准完成时间*:</label></td>
               <td><input class="easyui-datebox" type="text" name="xmyjwcsj" required="true" ></input></td></tr>
           <tr><td><label for="sfwdhy">所服务的国民经济行业*:</label></td>
               <td><select  id="sfwd" name="sfwdhy"><option>------请选择一种经济行业-------</option></select></td>
               <td align="right"><label for="hdlx">活动类型*:</label></td>
               <td><select id="hdlx" name="hdlx"><option>------请选择一种活动类型-------</option></select></td></tr>
           <tr><td><label for="wtfzr">项目委托单位法人代表/负责人*:</label></td>
               <td><input class="easyui-validatebox" type="text" id="wtfzr" name="wtfzr" required="true" ></input></td>
               <td align="right"><label for="post_code">邮编*:</label></td>
               <td><input class="easyui-validatebox" type="text" id="post_code" name="post_code" required="true" ></input></td></tr>
           <tr><td><label for="Desicion_Line">联系地址*:</label></td>
               <td><input class="easyui-validatebox" type="text" id="Desicion_Line" name="Desicion_Line" required="true" ></input></td>
               <td align="right"><label for="Project_Budget">合同经费*:</label></td>
               <td><input class="easyui-validatebox" type="text" id="Project_Budget" name="Project_Budget" required="true" ></input></td></tr>
           </table>
         </fieldset>
         </form>
         <form id="fzr" name="form2" method="post" action="proApplicationSub2.jsp">
          <fieldset>
          <legend>负责人(带*号为必填项)</legend>
           <table>
            <tr><td><label for="User_ID">负责人编号*:</label></td>
                <td><input class="easyui-validatebox" type="text" id="User_ID" name="User_ID" required="true" ></input></td>
                 <%
                   String userId= request.getParameter("User_ID");
                   String sql = "select * from user where userId="+userId;
                   ResultSet rs = dbConn.doQuery(sql);
                     if(rs.next()){
                   %>
                <td alig n="right"><label for="UserName">负责人*:</label></td>
                <td><input class="easyui-validatebox" type="text" id="UserName" name="UserName" required="true" value='<%=rs.getString("UserName") %>' disabled></input></td></tr>
            <tr><td><label for="msn">院系所部中心*:</label></td>
                <td><input class="easyui-validatebox" type="text" id="msn" name="msn" required="true" value='<%=rs.getString("msn") %>' disabled></input></td>
                <td align="right"><label for="type">人员性质*:</label></td>
                <td><input class="easyui-validatebox" type="text" id="type" name="type" required="true" value='<%=rs.getString("type") %>' disabled></input></td></tr>
            <tr><td><label for="Role_ID">角色*:</label></td>
                <td><select id="role" name="Role_ID"><option>----请选择一种角色-----</option></select></td>
                <td align="right"><label for="grgzl">个人工作量比例*:</label></td>
                <td><input class="easyui-validatebox" type="text" id="grgzl" name="grgzl" required="true" ></input></td></tr>
            <tr><td><label for="xb">性别*:</label></td>
                <td><select id="xb" name="xb"><option><%=rs.getString("xb") %></option></select></td>
                <td align="right"><label for="mz">民族:</label></td>
                <td><input class="easyui-validatebox" type="text" id="mz" name="mz"></input></td></tr>
            <tr><td><label for="zgxl">最高学历:</label></td>
                <td><select id="zgxl" name="zgxl"><option>-----请选择最高学历-----</option></select></td>
                <td align="right"><label for="zgxw">最高学位:</label></td>
                <td><select id="zgxw" name="zgxw"><option>-----请选择最高学位-----</option></select></td></tr>
            <tr><td><label for="zw">专业职务*:</label></td>
                <td><select id="zw" name="zw"><option>------请选择职务------</option></select></td>
                <td align="right"><label for="phone">联系电话:</label></td>
                <td><input class="easyui-validatebox" type="text" id="phone" name="phone" required="true" ></input></td></tr>
             <tr><td><label for="Mob">手机:</label></td>
                <td><input class="easyui-validatebox" type="text" id="Mob" name="Mob" required="true" ></input></td>
                <td align="right"><label for="email">电子邮箱:</label></td>
                <td><input class="easyui-validatebox" type="text" id="email" name="email" required="true" ></input></td></tr>
            <tr><td><label for="csrq">出生日期:</label></td>
                <td><input class="easyui-datebox" type="text" id="csrq" name="csrq" required="true" ></input></td>
                <td align="right"><label for="bz">工作所属学院:</label></td>
                <td><input class="easyui-validatebox" type="text" id="bz" name="bz" required="true"  value='<%=rs.getString("bz") %>' disabled></input></td></tr>
            </table>
        </fieldset>
         <fieldset>
          <legend>项目其他信息(带*号为必填项)</legend>
           <table>
            <tr><td><label for="xmht">项目合同*:</label></td>
                <td><input class="easyui-validatebox" type="file" id="xmht" name="xmht" required="true" ></input></td></tr>
             <tr><td><label for="beiz">备注:</label></td>
                <td><textarea rows="5" cols="60"></textarea></td></tr>
            </table>
        </fieldset>
</form>
<%} %>
  <p align="center">
         <input type="submit" name="submit"  value="提交" />
         <input type="reset" name="reset"  value="重置"/> 
        </p>
  </body>

</html>

怎么从负责人编号的输入框中获取到User_ID,然后传递到 String userId= request.getParameter("User_ID");
                   String sql = "select * from user where userId="+userId;
                   ResultSet rs = dbConn.doQuery(sql);

                     if(rs.next()){

这些话。

而且怎么将两个form提交上去啊?

 

加载中
返回顶部
顶部