用jsp+mysql制作班级留言表:留言用户名、留
1个回答
展开全部
<%@ 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>留言给我</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
textarea {
FONT: 12px Tahoma;
COLOR: #333333;
margin-top: 3px;
margin-bottom: 3px;
}
.input1 {
width: 300px;
height: 25px;
margin-top: 3px;
margin-bottom: 3px;
}
.input2 {
width: 150px;
height: 25px;
margin-top: 3px;
margin-bottom: 3px;
}
.submit1 {
width: 50px;
border: #CCCCCC solid 1px;
height: 30px;
background: #FFFFFF
}
#form1 tr th {
text-align: right;
}
input {
text-align: left;
}
body {
font-family: "微软雅黑", Verdana, sans-serif, "宋体";
color: #333;
}
.mybutton {
width: 70px;
height: 25px;
margin-top: 5px;
margin-bottom: 5px;
text-align: center;
}
h1 {
margin-top: 100px;
margin-bottom: 50px;
color: #999;
font-weight: bold;
font-size: 36px;
}
-->
</style>
<script>
function addCheck() {
var name = document.getElementById("name").value;
var title = document.getElementById("title").value;
var content = document.getElementById("content").value;
if (name == "") {
alert("姓名容都不能为空!")
document.getElementById("name").focus();
return false;
}
if (title == "") {
alert("主题都不能为空!")
document.getElementById("title").focus();
return false;
}
if (content == "") {
alert("内容不能为空!")
document.getElementById("content").focus();
return false;
}
}
</script>
</head>
<body>
<table width="400" align="center" cellpadding="2"
cellspacing="0">
<tr>
<td colspan="2"><h1> 留言本 </h1></td>
</tr>
<form name="form1" id="form1"
action="<%=basePath%>servlet/MessageServlet" method="post"
onSubmit="javascript: return addCheck()">
<tr>
<th width="70" align="right"> 姓名: </th>
<td width="280" align="left"><input name="name" type="text" class="input2" id="name"></td>
</tr>
<tr>
<th > 主题: </th>
<td><input name="title" type="text" class="input1"></td>
</tr>
<tr>
<th ><span class="STYLE1">留言</span>: </th>
<td ><textarea name="content" id="content" cols="60" rows="5"></textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="submit" id="submit" value="提交留言"class="mybutton">
<input type="button" name="submit" id="submit" value="查看留言"
onclick="window.location.href('<%=basePath%>servlet/MessageServlet?action=list&&p=1')" class="mybutton">
<input type="reset" name="reset" id="reset" value="重新填写" class="mybutton">
<input name="action" type="hidden" id="check" value="add"></td>
</tr>
</form>
</table>
</body>
</html>
<%
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>留言给我</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
<!--
textarea {
FONT: 12px Tahoma;
COLOR: #333333;
margin-top: 3px;
margin-bottom: 3px;
}
.input1 {
width: 300px;
height: 25px;
margin-top: 3px;
margin-bottom: 3px;
}
.input2 {
width: 150px;
height: 25px;
margin-top: 3px;
margin-bottom: 3px;
}
.submit1 {
width: 50px;
border: #CCCCCC solid 1px;
height: 30px;
background: #FFFFFF
}
#form1 tr th {
text-align: right;
}
input {
text-align: left;
}
body {
font-family: "微软雅黑", Verdana, sans-serif, "宋体";
color: #333;
}
.mybutton {
width: 70px;
height: 25px;
margin-top: 5px;
margin-bottom: 5px;
text-align: center;
}
h1 {
margin-top: 100px;
margin-bottom: 50px;
color: #999;
font-weight: bold;
font-size: 36px;
}
-->
</style>
<script>
function addCheck() {
var name = document.getElementById("name").value;
var title = document.getElementById("title").value;
var content = document.getElementById("content").value;
if (name == "") {
alert("姓名容都不能为空!")
document.getElementById("name").focus();
return false;
}
if (title == "") {
alert("主题都不能为空!")
document.getElementById("title").focus();
return false;
}
if (content == "") {
alert("内容不能为空!")
document.getElementById("content").focus();
return false;
}
}
</script>
</head>
<body>
<table width="400" align="center" cellpadding="2"
cellspacing="0">
<tr>
<td colspan="2"><h1> 留言本 </h1></td>
</tr>
<form name="form1" id="form1"
action="<%=basePath%>servlet/MessageServlet" method="post"
onSubmit="javascript: return addCheck()">
<tr>
<th width="70" align="right"> 姓名: </th>
<td width="280" align="left"><input name="name" type="text" class="input2" id="name"></td>
</tr>
<tr>
<th > 主题: </th>
<td><input name="title" type="text" class="input1"></td>
</tr>
<tr>
<th ><span class="STYLE1">留言</span>: </th>
<td ><textarea name="content" id="content" cols="60" rows="5"></textarea></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" name="submit" id="submit" value="提交留言"class="mybutton">
<input type="button" name="submit" id="submit" value="查看留言"
onclick="window.location.href('<%=basePath%>servlet/MessageServlet?action=list&&p=1')" class="mybutton">
<input type="reset" name="reset" id="reset" value="重新填写" class="mybutton">
<input name="action" type="hidden" id="check" value="add"></td>
</tr>
</form>
</table>
</body>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询