在注册页面中设置一个下拉菜单,让用户能够选择自己来自的地区。代码如下
<html>
<body>
请输入自己的信息进行注册:
<form action="<%=request.getContextPath() %>/selectcotain.jsp" method="post">
请您输入账号:<input name="account" type="text"><BR>
请您输入密码:<input name="password" type="password"><BR>
请您输入家乡:
<select name="home">
<option value="beijing">北京</option>
<option value="shanghai">上海</option>
<option value="tianjin">天津</option>
</select>
<input type="submit" value="注册">
</form>
</body>
</html>
下面是获取数据的代码:
<%@ page language="java" contentType ="text/html; charset=gb2312" %>
<html>
<body>
<%
String home=request.getParameter("home");
out.println("家乡为:"+home);
%>
</body>
</html>