- 爱易网页
-
Java教程
- javacript如何获取jsp页面中多个name一样的text数据
日期:2014-05-18 浏览次数:20722 次
javacript怎么获取jsp页面中多个name一样的text数据?
<%@ page language= "java " import= "java.util.* " pageEncoding= "ISO-8859-1 "%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+ ":// "+request.getServerName()+ ": "+request.getServerPort()+path+ "/ ";
%>
<%@ page import= "com.accp.dao.* "%>
<%@ page import= "com.accp.bean.* "%>
<%@ page import= "java.sql.* "%>
<%
ResultSet rs=new enterSubject().selectSub();
String number=null;
String subject=null;
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN ">
<html>
<head>
<base href= " <%=basePath%> ">
<title> My JSP 'answer.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 ">
<!--
-->
<script type= "text/javascript ">
function checkAnswer()
{
var answer=document.getElementById( "answer ");
}
</script>
</head>
<form name= "form " action= "/ExamOnline/CheckAnswer " onSubmit= "return checkAnswer() ">
<table align= "center ">
<tr> </tr>
<%
while(rs.next())
{
number=rs.getString( "number ");
subject=rs.getString( "subject ");
%>
<tr>
<td> <%=number%> </td>
</tr>
<tr>
<td> <%=subject%> </td>
</tr>
<tr>
<td> <input type= "text " id= "answer " name= "answer "/> </td>
</tr>
<%} %>
</table>
</br>
<input type= "Submit " value= "submit "/>
</form>
<body>
</body>
</html>
如果我有10条纪录,用户输入答案提交后,如何判断是否有空的答案?
如果有空的答案如何用 "error "填充?