zoukankan      html  css  js  c++  java
  • 登录注册

    主程序为

    <%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>首页</title>

    </head>
    <body>
    <div align="center">

    <div class="a">
    <a href="add.jsp">课程信息添加</a>
    </div>
    <div class="a">
    <a href="CourseServlet?method=list">课程信息修改</a>
    </div>
    <div class="a">
    <a href="del.jsp">课程信息删除</a>
    </div>
    <div class="a">
    <a href="search.jsp">课程信息查询</a>
    </div>
    </div>
    </body>
    </html>

    2.添加程序

    <%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <title>Insert title here</title>

    </head>
    <body>
    <%
    Object message = request.getAttribute("message");
    if(message!=null && !"".equals(message)){

    %>
    <script type="text/javascript">
    alert("<%=request.getAttribute("message")%>");
    </script>
    <%} %>
    <div align="center">
    <h1 style="color: black;">课程信息录入</h1>
    <a href="index.jsp">返回主页</a>
    <form action="CourseServlet?method=add" method="post" onsubmit="return check()">
    <div class="a">
    课程名称<input type="text" id="name" name="name"/>
    </div>
    <div class="a">
    任课教师<input type="text" id="teacher" name="teacher" />
    </div>
    <div class="a">
    上课地点<input type="text" id="classroom" name="classroom" />
    </div>
    <div class="a">
    <button type="submit" class="b">保&nbsp;&nbsp;&nbsp;存</button>
    </div>
    </form>
    </div>
    <script type="text/javascript">
    function check() {
    var name = document.getElementById("name");
    var teacher = document.getElementById("teacher");
    var classroom = document.getElementById("classroom");

    //非空
    if(name.value == '') {
    alert('课程名称为空');
    name.focus();
    return false;
    }
    if(teacher.value == '') {
    alert('教师为空');
    teacher.focus();
    return false;
    }
    if(classroom.value == '') {
    alert('上课地点为空');
    classroom.focus();
    return false;
    }

    //教师
    if(teacher.value != '王建民' && teacher.value != '王辉' && teacher.value != '刘丹' && teacher.value != '刘立嘉' && teacher.value != '杨子光'){
    alert('教师名称错误');
    return false;
    }

    //教室
    if(!/^基教/.test(classroom.value) && !/^一教/.test(classroom.value) && !/^二教/.test(classroom.value) && !/^三教/.test(classroom.value)) {
    alert('上课地点错误');
    return false;
    }
    }
    </script>
    </body>
    </html>

  • 相关阅读:
    poj 2485 Highways 最小生成树
    hdu 3415 Max Sum of MaxKsubsequence
    poj 3026 Borg Maze
    poj 2823 Sliding Window 单调队列
    poj 1258 AgriNet
    hdu 1045 Fire Net (二分图匹配)
    poj 1789 Truck History MST(最小生成树)
    fafu 1181 割点
    减肥瘦身健康秘方
    人生的问题
  • 原文地址:https://www.cnblogs.com/PSLQYZ/p/11717156.html
Copyright © 2011-2022 走看看