zoukankan      html  css  js  c++  java
  • 双表的增删改查-add.jsp

    <%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>添加页面</title>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath() %>/css/index2.css">
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.8.3.min.js"></script>
    </head>
    <body>
    <form id="fid">
    <div class="container">
    <table class="table">
    <thead class="thead-light">
    <tr>
    <th scope="col">姓名<input type="text" name="name" > </th>
    </tr>
    <tr>
    <th scope="col">身份证编号<input type="text" name="sfz" > </th>
    </tr>
    <tr>
    <th scope="col">电话<input type="text" name="telephone" > </th>
    </tr>
    <tr>
    <th scope="col">性别<input type="radio" name="grader" value="1" >男<input type="radio" name="grader" value="2" >女 </th>
    </tr>
    <tr>
    <th scope="col">省:<select name="province" onchange="shen()" id="ss">
    <c:forEach items="${province}" var="d">
    <option value="${d.id}">${d.sname}</option>
    </c:forEach>
    </select></th>
    </tr>
    <tr>
    <th scope="col">市<select name="town" onchange="shi()" id="town">
    </select> </th>
    </tr>
    <tr>
    <th scope="col">县<select name="county" onchange="xian()" id="county">
    </select> </th>
    </tr>
    <tr>
    <th scope="col">科室<select name="desk">
    <c:forEach items="${listDepart}" var="d">
    <option value="${d.id}">${d.kname}</option>
    </c:forEach>

    </select> </th>
    </tr>
    <tr>
    <th scope="col">擅长
    <c:forEach items="${shanchang}" var="s" >
    <input type="checkbox" name="scname" value="${s.id}" >${s.sname}
    </c:forEach>
    </th>
    </tr>
    <tr>
    <th scope="col">入职日期<input type="date" name="rzdate" ></th>
    </tr>
    <tr>
    <th scope="col">出生日期<input type="date" name="birthday" ></th>
    </tr>
    <tr>
    <th scope="col">
    <input type="file" name="file" value="${d.touxiang}" >
    </th>
    </tr>
    <tr>
    <td>
    <button type="button" class="btn btn-primary" onclick="xg()" >保存</button>
    </td>
    </tr>
    </thead>
    </table>
    </div>
    </form>

    <script type="text/javascript">
    function xg(){
    var formData = new FormData($("#fid")[0]);
    $.ajax({
    url:'/add',
    type:'post',
    processData:false,
    data:formData,
    contentType:false,
    success:function(obj){
    if(obj>0){
    alert("添加成功");
    location.href="/list";
    }else{
    alert("添加失败");
    location.href="/update";
    }
    }
    })
    }
    function shen() {
    var id = $("#ss").val();
    $.ajax({
    url:'/city',
    data:{id:id},
    type:'post',
    dataType:'JSON',
    success:function(obj){
    $("#county").empty();
    $("#town").empty();
    for ( var i in obj) {
    $("#town").append("<option value="+obj[i].id+" >"+obj[i].sname+"</option>")
    }
    }
    })
    }
    function shi() {
    var id = $("#town").val();
    $.ajax({
    url:'/city',
    data:{id:id},
    type:'post',
    dataType:'JSON',
    success:function(obj){
    $("#county").empty();
    for ( var i in obj) {
    $("#county").append("<option value="+obj[i].id+" >"+obj[i].sname+"</option>")
    }
    }
    })
    }
    </script>
    </body>
    </html>

  • 相关阅读:
    java基础英语---第二天
    树莓派的版本
    Linux系统下安装.deb文件
    在Raspberry上安装ROS
    树莓派文件权限的转换
    树莓派中Linux的相关命令
    raspberry连接ssh和vnc
    链表的建立及释放
    一些小细节问题
    关于构建二维动态内存(堆)及释放
  • 原文地址:https://www.cnblogs.com/liuzhaolong/p/12874588.html
Copyright © 2011-2022 走看看