📄 person.jsp
字号:
<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>add person</title>
<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/engine.js'> </script>
<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/util.js'> </script>
<script type='text/javascript' src='<%=request.getContextPath()%>/dwr/interface/cityDao.js'> </script>
<script language="JavaScript" src='<%=request.getContextPath()%>/js/prototype.js'></script>
<script type="text/javascript">
function form1_submit()
{
if(document.form1.provinceId.value=="")
{
alert("请选择省份");
return false;
}
if(document.form1.cityId.value=="")
{
alert("请选择城市");
return false;
}
if(document.form1.username.value=="")
{
alert("请输入用户名");
return false;
}
if(document.form1.password.value=="")
{
alert("请输入密码");
return false;
}
if(document.form1.checkPassword.value==""||document.form1.checkPassword.value!=document.form1.password.value)
{
alert("请选择省份");
return false;
}
form1.submit();
}
</script>
<script type="text/javascript">
//根据省id(provinceId)查询所属城市
function queryCity()
{
var provinceId = $("provinceId").value;
//默认为不选择
if(provinceId == '0')
{
$("cityId").options.length='0';
}
else
{
cityDao.queryCityById(provinceId,cityCallback);
}
}
//根据省id查询所属城市的回调函数
function cityCallback(cities)
{
$("cityId").options.length='0';
//每次获得新的数据的时候先把每二个下拉框架的长度清0
for(var i=0;i< cities.length;i++)
{
var value = cities[i].id;
var text = cities[i].name;
var option = new Option(text, value);
//根据每组value和text标记的值创建一个option对象
try
{
$("cityId").add(option);//将option对象添加到第二个下拉框中
}
catch(e)
{ }
}
}
//查询所属城市回调函数
function change()
{
queryCity();
}
</script>
</head>
<body>
<center>
<form name="form1" action="person.do?dispatch=save" method="post"
onSubmit="return form1_submit()">
<table>
<tr>
<td>省份:</td>
<td><select id="provinceId" name="provinceId" onChange="change();" style="width:150px">
<option value="0" selected>---请选择---</option>
<logic:iterate id="province" name="ProvinceList">
<option value="<bean:write name="province" property="id"/>" >
<bean:write name="province" property="name"/>
</option>
</logic:iterate>
</select></td>
<td>城市:</td>
<td><select id="cityId" name="cityId" style="width:150px">
<option value="" selected>---请选择---</option>
</select>
</td>
</tr>
<tr>
<td>用户名:</td>
<td><input type="text" name="username" style="width:150px"></td>
<td>密码:</td>
<td><input type="password" name="password" style="width:150px"></td>
</tr>
<tr>
<td>确认密码:</td>
<td><input type="password" name="password" style="width:150px"></td>
<td>email:</td>
<td><input type="text" name="email" style="width:150px"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="提交"></td>
<td><input type="reset" value="重置"></td>
<td></td>
</tr>
</table>
</form>
</center>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -