日期:2014-05-17  浏览次数:20626 次

Jsp Html 实现下拉框和组合下拉框(1)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style type="html/css">
<!--
.STYLE1{
     color:#FF0000;
     font-size:large;
     width:150px;
}
-->
</style>
</head>
<body>
<form name="form1" action="list.jsp" method="post">
<div>
<span class="STYLE1">下拉列表框</span>
<!-- name属性在request对象中取值时使用 -->
<select name="select">
   <option>星期日</option>
   <option>星期六</option>
   <option>星期五</option>
   <!-- selected属性设置默认选中 -->
   <option selected="selected">星期四</option>
   <option>星期三</option>
   <option>星期二</option>
   <option>星期一</option>
   </select>
</div>
<hr />
<input name="ok" type="submit" value="提交">
</form>
</body>
</html>



<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h3>您选择的是:</h3>
<h2>
<font color="red">
<%
//设置request对象的字符编码集,避免中文显示的乱码
request.setCharacterEncoding("UTF-8");
//获取下拉列表框的值
String  date=request.getParameter("select");
//如果设置了mutiple属性
//String[] date=request.getParameterValues("select");
out.println(date);
%>
</font>
</h2>

</body>
</html>