jsp中下拉表单/菜单select option的用法实例js判断是否为空值javascript。jsp简单的教程,jsp下拉菜单使用,javascript判断select option。
jsp表单信息提交页面jsp源码:
<%@ page contentType=”text/html; charset=gb2312″ language=”java” import=”java.sql.*” errorPage=”" %>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″>
<title>获取下拉列表/菜单的值</title>
<link href=”css/style.css” type=”text/css” rel=”stylesheet”>
</head>
<script language=”javascript” type=”">
function checkEmpty(form){
for(i=0;i<form.length;i++){
if(form.elements[i].value==”"){
alert(“表单信息不能为空”);
return false;
}
}
}
</script>
<body background=”beijing.gif”><div align=”center”>
选择下拉列表/菜单的值
<form name=”form” method=”post” action=”dealwith.jsp” onSubmit=”return checkEmpty(form)”>
<table width=”270″ border=”0″>
<tr>
<td width=”78″ height=”20″>请选择图书</td>
<td width=”182″>
<select name=”select”>
<option value=”">请选择</option>
<option value=”JSP数据库开发完全手册”>JSP数据库开发完全手册</option>
<option value=”JSP数据库案例精选”>JSP数据库案例精选</option>
<option value=”Java数据库案例精选”>Java数据库案例精选</option>
<option value=”JSP范例宝典”>JSP范例宝典</option>
<option value=”JSP技术大全”>JSP技术大全</option>
</select>
</td>
</tr>
</table>
<input type=”submit” name=”Submit” value=”提交”>
</form>
</div>
</body>
</html>
jsp接收下拉表单/菜单页面,jsp源码:
<%@ page contentType=”text/html; charset=gb2312″ language=”java” import=”java.sql.*” errorPage=”" %>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=gb2312″>
<title>获取下拉列表/菜单的值</title>
<link href=”css/style.css” type=”text/css” rel=”stylesheet”>
</head>
<%request.setCharacterEncoding(“gb2312″);%>
<body background=”beijing.gif”><div align=”center”>
获取下拉列表/菜单的值
<table width=”352″ border=”0″>
<tr>
<td width=”165″ height=”20″>获取下拉列表/菜单的值
:</td>
<td width=”177″><%=request.getParameter(“select”)%></td>
</tr>
</table>
<a href=”index.jsp”>返回</a></div>
</body>
</html>