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

Jsp Html实现下拉框和组合下拉框
<!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>
<form name="form1" action="grouplist.jsp" method="post">
<label for="WebDesign">请选择您的兴趣爱好</label>
<select id="WebDesign" name="WebDesign">
<optgroup label="Client">
     <option value="HTML">HTML</option>
     <option value="CSS">CSS</option>
     <option  value="JavaScript">JavaScript</option>
</optgroup>
<optgroup label="server" >
     <option value="PHP">PHP</option>
     <option value="ASP">ASP</option>
     <option value="JSP">JSP</option>
</optgroup> 
<optgroup label="database">
     <option value="Access">Access</option>
     <option value="MySql">MySql</option>
     <option value="SQLServer">SQLServer</option>
</optgroup>
</select>
<p>Client,server ,database这三个选项是不能选择的</p>
<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>
<%
//设置request对象的字符编码集,避免中文显示的乱码
request.getParameter("UTF-8");
String interest=request.getParameter("WebDesign");
out.println("<i>");
out.println(interest);
out.println("</i>");
%>
</body>
</html>