我主要是这个意思 城市 省份是在A.jsp就是我在这个页面修改个人资料时候选择了相应的城市 省份 点击下一步进入到另外一个b.jsp页面后,然后我想点击上一步回到A.jsp页面 重新选择城市,当我回到A.jsp页面时,显示的就是我刚开始选择的省份 城市
解决方案 »
- 新手,基于s2sh做了个增删改查的demo,想要通过搜索id得到学生信息,该怎么做?
- Struts2拦截器如何对jsp页面做拦截?
- jsp调用客户端jdk问题
- 单例模式下面的问题??据说是很一般的问题。。
- 乱码问题
- jsp能从本页的input=text或者其它控件中取数据吗?
- 大家来看一下我的思路对不对,可行不?急
- 为了防止用户在一个再系统使用过程中,再一次打开浏览器进入系统,我该怎么做?(也就是说如何阻止用户两次登陆)
- 用过struts的高手介绍一下struts的优缺点(最好是自己的观点,不要抄整片的文章)!
- 求大神指导,struts2加入核心过滤器后,所有页面404。。。。。。。
- 格式化字符串问题
- 关于list的应用问题
直接在一个jsp页面中用js函数来实现,当在一个下拉框里面选择了某个省,可以在另外的一个下拉框显示该省的所有城市。这样不就更简单吗?
//定义了城市的二维数组,里面的顺序跟省份的顺序是相同的。通过selectedIndex获得省份的下标值来得到相应的城市数组
var city=[
["北京","天津","上海","重庆","香港","澳门"],
["石家庄","唐山","秦皇岛","邯郸","邢台","保定","张家口","承德","沧州","廊坊","衡水"],
["太原","大同","阳泉","长治","晋城","朔州","晋中","运城","忻州","临汾","吕梁"],
["呼和浩特","包头","乌海","赤峰","通辽","鄂尔多斯","呼伦贝尔","巴彦淖尔","乌兰察布","兴安","锡林郭勒","阿拉善"]
]
function getCity(){
//获得省份下拉框的对象
var sltProvince=document.userupdateForm.province;
//获得城市下拉框的对象
var sltCity=document.userupdateForm.city;
//得到对应省份的城市数组
var provinceCity=city[sltProvince.selectedIndex - 1];
//清空城市下拉框,仅留提示选项
// sltCity.length=1;
//将城市数组中的值填充到城市下拉框中
for(var i=0;i<provinceCity.length;i++){
sltCity[i+1]=new Option(provinceCity[i],provinceCity[i]);
}
}</script>
</head>
<table>
<form name="userupdateForm">
<tr><td>请选择企业所在城市<font color="red">*</font></td>
<td><select name="province" onChange="getCity()">
<option value="null" selected="selected">请选择所在省份</option>
<option value="直辖市">直辖市</option>
<option value="河北">河北</option>
<option value="山西">山西</option>
</select>
<select name="city">
<option selected="selected" value="null">请选择所在城市</option>
</select><font color="red"><html:errors property="city"/></font></td></tr>
</table>
</table>
这是我的代码 我也知道1 2楼的意思 但是传值要怎么接收了 ?
3楼还没有明白我的意思.
我是在b.jsp页面点击上一步 触发了window.history.go(-1)返回这个事件
-------------
这个似乎有点难度,我没有解决过,我觉得你可以直接用链接返回上一步
<script language=javascript>
window.onload = historyOncemore;
window.onbeforeunload = fixHistory; function fixHistory() //记住历史
{
document.all("theHistoryRecord").value=document.all("thedetailtableDIV").innerHTML.replace(/\n/g,"");
} function historyOncemore() //恢复历史
{
if (document.all("theHistoryRecord").value!="")
{document.all("thedetailtableDIV").innerHTML=document.all("theHistoryRecord").value;
}
}
</script>
<div id="thedetailtableDIV">你的内容</div>
<input name="theHistoryRecord" type=hidden value="">
采用你的方法 在ie下可以显示 但是遨游 火狐都不能显示 都只是显示出来 请选择所在省份 请选择城市
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>aaa</title><script language=javascript>
window.onload = historyOncemore;
window.onbeforeunload = fixHistory; var city=[
["北京","天津","上海","重庆","香港","澳门"],
["石家庄","唐山","秦皇岛","邯郸","邢台","保定","张家口","承德","沧州","廊坊","衡水"],
["太原","大同","阳泉","长治","晋城","朔州","晋中","运城","忻州","临汾","吕梁"],
["呼和浩特","包头","乌海","赤峰","通辽","鄂尔多斯","呼伦贝尔","巴彦淖尔","乌兰察布","兴安","锡林郭勒","阿拉善"]
]
function getCity(){
//获得省份下拉框的对象
var sltProvince=document.userupdateForm.province;
//获得城市下拉框的对象
var sltCity=document.userupdateForm.city;
//得到对应省份的城市数组
var provinceCity=city[sltProvince.selectedIndex - 1];
//清空城市下拉框,仅留提示选项
// sltCity.length=1;
//将城市数组中的值填充到城市下拉框中
for(var i=0;i<provinceCity.length;i++){
sltCity[i+1]=new Option(provinceCity[i],provinceCity[i]);
}
} function fixHistory() //记住历史
{
document.all("theHistoryRecord").value=document.all("thedetailtableDIV").innerHTML.replace(/\n/g,"");
} function historyOncemore() //恢复历史
{
if (document.all("theHistoryRecord").value!="")
{document.all("thedetailtableDIV").innerHTML=document.all("theHistoryRecord").value;
}
} function selectallcheckbox(obj) //全选或全不选
{
var tureorfalse=obj.checked;
var theDetail=tbDetailUsed.rows;
for(var i=0;i<theDetail.length-1;i++)
{
theDetail[i].all("record_select").checked=tureorfalse;
}
}
function submitProcess()
{
document.userupdateForm.submit();
}
</script>
</head><body>
<form name="userupdateForm" action="about:结果页面">
<input type="button" value="完成" class="bottom" onclick="submitProcess();">
<div width=100% id=thedetailtableDIV>
<select name="province" onChange="getCity()">
<option value="null" selected="selected">请选择所在省份</option>
<option value="直辖市">直辖市</option>
<option value="河北">河北</option>
<option value="山西">山西</option>
</select>
<select name="city">
<option selected="selected" value="null">请选择所在城市</option>
</select><font color="red"><html:errors property="city"/></font></td></tr>
</div>
</form>
<input name="theHistoryRecord" type=hidden value="">
</body></html>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>updateuser</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
--><script type="text/javascript">
window.onload = historyOncemore;
window.onbeforeunload = fixHistory;
//定义了城市的二维数组,里面的顺序跟省份的顺序是相同的。通过selectedIndex获得省份的下标值来得到相应的城市数组
var city=[
["北京","天津","上海","重庆","香港","澳门"],
["石家庄","唐山","秦皇岛","邯郸","邢台","保定","张家口","承德","沧州","廊坊","衡水"],
["太原","大同","阳泉","长治","晋城","朔州","晋中","运城","忻州","临汾","吕梁"],
["呼和浩特","包头","乌海","赤峰","通辽","鄂尔多斯","呼伦贝尔","巴彦淖尔","乌兰察布","兴安","锡林郭勒","阿拉善"]
];
function getCity(){
//获得省份下拉框的对象
var sltProvince=document.userupdateForm.province;
//获得城市下拉框的对象
var sltCity=document.userupdateForm.city;
//得到对应省份的城市数组
var provinceCity=city[sltProvince.selectedIndex - 1];
//清空城市下拉框,仅留提示选项
// sltCity.length=1;
//将城市数组中的值填充到城市下拉框中
for(var i=0;i<provinceCity.length;i++){
sltCity[i+1]=new Option(provinceCity[i],provinceCity[i]);
}
} function fixHistory() //记住历史
{
document.all("theHistoryRecord").value=document.all("thedetailtableDIV").innerHTML.replace(/\n/g,"");
} function historyOncemore() //恢复历史
{
if (document.all("theHistoryRecord").value!="")
{document.all("thedetailtableDIV").innerHTML=document.all("theHistoryRecord").value;
}
} function selectallcheckbox(obj) //全选或全不选
{
var tureorfalse=obj.checked;
var theDetail=tbDetailUsed.rows;
for(var i=0;i<theDetail.length-1;i++)
{
theDetail[i].all("record_select").checked=tureorfalse;
}
}
function submitProcess()
{
document.userupdateForm.submit();
}</script>
</head>
<body>
<table width="990" height="750">
<tr><logic:iterate id="user" name="userdata" scope="session">
<td width="200"><jsp:include page="/jsp/menu.jsp" flush="true"/></td>
<td align="center" valign="top"><table align="center">
<html:form action="/userupdate" method="post" onsubmit="return validateuserupdateForm(this)" focus="companyname">
<tr><td>用户名 <font color="red">*</font></td>
<td><html:text property="username" disabled="true" value="${user.udName}"/><FONT color="red"><html:errors property="username"/></FONT></td></tr>
<tr><td>请选择企业所在行业<font color="red">*</font></td>
<td><select name="business">
<option value="null" selected="selected">请选择</option>
<option value="医药卫生">医药卫生</option>
<option value="建筑建材">建筑建材</option>
<option value="冶金矿产">冶金矿产</option>
<option value="石油化工">石油化工</option>
</select><font color="red"><html:errors property="business"/></font></td>
</tr>
<tr><td>请选择企业所在城市<font color="red">*</font></td>
<td><div width=100% id=thedetailtableDIV><select name="province" onChange="getCity()">
<option value="null" selected="selected">请选择所在省份</option>
<option value="直辖市">直辖市</option>
<option value="河北">河北</option>
<option value="山西">山西</option>
<option value="内蒙古">内蒙古</option>
</select>
<select name="city">
<option selected="selected" value="null">请选择所在城市</option>
</select><font color="red"><html:errors property="city"/></font></td></tr></div>
<tr><td>请输入企业地址 </td>
<td><html:text property="companydress" value="${user.udCompdress}"/><font color="red"><html:errors property="companydress"/></font></td></tr>
<tr><td colspan="2" align="center">
<html:hidden property="status" value="update"/>
<html:hidden property="username" value="${user.udName}"/>
<html:submit property="update" value="提交更改" onclick="submitProcess();" />
<input name="theHistoryRecord" type=hidden value="">
</td></tr>
</html:form> </table>
</td></logic:iterate></tr>
</table>
<
<input name="theHistoryRecord" type=hidden value="">
</body>
</html>我的jsp页面是这么修改的 可是显示不出来。
<input id="theHistoryRecord" name="theHistoryRecord" type=hidden value="">看看
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>aaa</title><script language=javascript>
window.onload = historyOncemore;
window.onbeforeunload = fixHistory; var city=[
["北京","天津","上海","重庆","香港","澳门"],
["石家庄","唐山","秦皇岛","邯郸","邢台","保定","张家口","承德","沧州","廊坊","衡水"],
["太原","大同","阳泉","长治","晋城","朔州","晋中","运城","忻州","临汾","吕梁"],
["呼和浩特","包头","乌海","赤峰","通辽","鄂尔多斯","呼伦贝尔","巴彦淖尔","乌兰察布","兴安","锡林郭勒","阿拉善"]
]
function getCity(t){
alert(document.getElementById("province").selectedIndex)
//获得省份下拉框的对象
var sltProvince=document.userupdateForm.province;
//获得城市下拉框的对象
var sltCity=document.userupdateForm.city;
//得到对应省份的城市数组
var provinceCity=city[sltProvince.selectedIndex - 1];
//清空城市下拉框,仅留提示选项
// sltCity.length=1;
//将城市数组中的值填充到城市下拉框中
for(var i=0;i<provinceCity.length;i++){
sltCity[i+1]=new Option(provinceCity[i],provinceCity[i]);
}
}
function getSelfCity(t){
alert(document.getElementById("city").selectedIndex)
} function fixHistory() //记住历史
{
document.getElementById("theHistoryRecord").value=document.getElementById("thedetailtableDIV").innerHTML.replace(/\n/g,"");
document.getElementById("index1").value = document.getElementById("province").selectedIndex;
document.getElementById("index2").value = document.getElementById("city").selectedIndex;
} function historyOncemore() //恢复历史
{
if (document.getElementById("theHistoryRecord").value!="")
{
document.getElementById("thedetailtableDIV").innerHTML=document.getElementById("theHistoryRecord").value;
document.getElementById("province").selectedIndex = document.getElementById("index1").value;
document.getElementById("city").selectedIndex = document.getElementById("index2").value;
}
} function submitProcess()
{
document.userupdateForm.submit();
}
</script>
</head><body>
<form name="userupdateForm" action="hehee.html">
<input type="button" value="完成" class="bottom" onclick="submitProcess();">
<div width=100% id="thedetailtableDIV">
<select id="province" name="province" onChange="getCity(this)">
<option value="" >请选择所在省份</option>
<option value="直辖市">直辖市</option>
<option value="河北">河北</option>
<option value="山西">山西</option>
</select>
<select id="city" name="city" onChange="getSelfCity(this)">
<option value="">请选择所在城市</option>
</select></td></tr>
</div></form>
<input name="theHistoryRecord" id="theHistoryRecord" type=hidden value="">
<input name="index1" id="index1" type=hidden value="">
<input name="index2" id="index2" type=hidden value="">
</body></html>
onload
getElementById
innerHTML
似乎各大浏览器都支持而firefox和IE两个浏览器都支持onbeforeunload 事件,傲游是ie内核呀,所以肯定支持