5月2日 RIA 周三

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">

    <title>My JSP 'add.jsp' starting page</title>

    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->

  <script type="text/javascript" src="js/jquery-1.8.2.js"></script>
  <script type="text/javascript" src="js/jquery.validate.js"></script>
  <script type="text/javascript">
    $(function (){
        //回显下拉列表
        $.ajax({
            url:"emp?m=dept",
            type:"post",
            data:$("#for").serialize(),
            dataType:"json",
            success:function(msg){
                for(var i in msg){
                    $("#s1").append("<option value="+msg[i].did+">"+msg[i].dname+"</option>");
                }
            }
        });

        $("#for").validate({
            rules:{
                eid:{required:true},
                ename:{required:true,minlength:2},
                age:{required:true,range:[18,99]},
                sex:{required:true},
                hobby:{required:true},
                birthday:{required:true,dateISO:true}
            },
            messages:{
                eid:"必须输入",
                ename:"必须输入",
                age:{required:"必须输入",minlength:"长度最少2位"},
                sex:"必须输入",
                hobby:"必须输入",
                birthday:{required:"必须输入",dateISO:"2000-12-12"}
            },
            submitHandler:function(){
                $.ajax({
                    url:"emp?m=add",
                    type:"post",
                    data:$("#for").serialize(),
                    dataType:"text",
                    success:function(msg){
                        if(msg>0){
                            location="emp?m=list";
                        }else{
                            location.reload();
                        }
                    }
                });
            }
        });
    });
  </script>
  </head>

  <body>
  <form id="for">
    eid:<input type="text" name="eid"><br>
    ename:<input type="text" name="ename"><br>
    age:<input type="text" name="age"><br>
    sex:<input type="radio" name="sex" value="男"><input type="radio" name="sex" value="女"><br>
    hobby:<input type="checkbox" name="hobby" value="上网">上网
    <input type="checkbox" name="hobby" value="唱歌">唱歌
    <input type="checkbox" name="hobby" value="看书">看书<br>
    birthday:<input type="text" name="birthday"><br>
    did:<select name="did" id="s1">

    </select><br>
    <input type="submit" value="添加">
  </form>
  </body>
</html>

哪有人一辈子不挨刀的,重要的,不是有没有被算计过,而是被算计过之后,有没有学会自省。被算计第一次,是失误;被算计第二次,是防心不足;被算计第三次,那就是无能了!
——君子江山《皇上滚开,本宫只劫财》

猜你喜欢

转载自blog.csdn.net/helloworld_1996/article/details/80171661