在一个jsp页面中新开一个窗口,如何将窗口中所作的修改传给原页面,同时让页面刷新显示??
请高手指教,定给分
原叶面如下:
<body bgcolor="#ffffff">
<img src=images/active/actCfgDeviceType.gif hspace=10>
<a href=# onclick="openwin('TCCType.jsp','width=500, height=250')">设备类型</a>
原类型是Windows XP<br>
修改后是??????
</body>
窗口中的内容如下:
<form>
<select name="type">
<option value="Unix">Unix </option>
<option value="Unknown">Unknown </option>
<option value="Windows 2000">Windows 2000 </option>
<option value="Windows 2003">Windows 2003 </option>
<option value="Windows 98">Windows 98 </option>
<option value="Windows XP" selected>Windows XP </option>
<option value="WindowsNT">WindowsNT </option>
</select>
</form>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<form>
<input type="submit" name="store" value="保存">
<input type="reset" name="reset" value="取消" onclick="window.close()">
</form>
</td>
</tr>
我在窗口中选择window 2000
如何在点击保存按钮后在原页面中显示出来??
请高手赐教
请高手指教,定给分
原叶面如下:
<body bgcolor="#ffffff">
<img src=images/active/actCfgDeviceType.gif hspace=10>
<a href=# onclick="openwin('TCCType.jsp','width=500, height=250')">设备类型</a>
原类型是Windows XP<br>
修改后是??????
</body>
窗口中的内容如下:
<form>
<select name="type">
<option value="Unix">Unix </option>
<option value="Unknown">Unknown </option>
<option value="Windows 2000">Windows 2000 </option>
<option value="Windows 2003">Windows 2003 </option>
<option value="Windows 98">Windows 98 </option>
<option value="Windows XP" selected>Windows XP </option>
<option value="WindowsNT">WindowsNT </option>
</select>
</form>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<form>
<input type="submit" name="store" value="保存">
<input type="reset" name="reset" value="取消" onclick="window.close()">
</form>
</td>
</tr>
我在窗口中选择window 2000
如何在点击保存按钮后在原页面中显示出来??
请高手赐教
<form name="theForm">
<input type="submit" name="store" value="保存" onClick="save()"><script lanuage="javascript">
var v=document.theForm.type.value;
parent.document.getElementById('s').innerHTML=v;
window.close();
</script>页面修改:修改后是<span id="s"></span>
parent.opener.document.theForm.type.value = this.type.value ;
}假设原页面中有
<form name=theForm>
<input name=type>
<script language="javascript">
function openScript(url,name, width, height){
var Win = window.open(url,name,'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=yes' );
}
</script>
<body bgcolor="#ffffff">
<a href=# onclick="openScript('sub1.html','pur',300,250)" >设备类型</a>
原类型是Windows XP<br>
<span id="s"></span>
</body>
</html> <html>
<script lanuage="javascript">
function save()
{
var v=document.theForm.type.value;
parent.document.getElementById('s').innerHTML=v;
window.close();
}
</script><body>
<form name="theForm">
<tr><td>
<select name="type">
<option value="Unix">Unix </option>
<option value="Unknown">Unknown </option>
<option value="Windows 2000">Windows 2000 </option>
<option value="Windows 2003">Windows 2003 </option>
<option value="Windows 98">Windows 98 </option>
<option value="Windows XP" selected>Windows XP </option>
<option value="WindowsNT">WindowsNT </option>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="store" value="保存" onClick="save()">
<input type="reset" name="reset" value="取消" onclick="window.close()">
</form>
</td>
</tr>
</body>
</html>没取到值呀! 一楼的朋友是如何做到的?
1.html:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis" />
<title>js</title>
</head><body>
<form id="form1" name="form1" method="post" action="">
<p>
<input type="button" name="Button" value="Button" onclick="window.open('2.html','','width=500, height=250')"/>
</p>
<p>
<input type="text" name="textfield" readonly="true"/>
</p>
</form>
</body>
</html>
2.html:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=shift_jis" />
<title>js2</title>
<script>
function tranValue() {
window.opener.document.form1.textfield.value=document.form2.selectbox.value;
parent.location.unload();
}
</script>
</head><body>
<form name="form2">
<select name="selectbox" onchange="tranValue()">
<option value="Unix">Unix </option>
<option value="Unknown">Unknown </option>
<option value="Windows 2000">Windows 2000 </option>
<option value="Windows 2003">Windows 2003 </option>
<option value="Windows 98">Windows 98 </option>
<option value="Windows XP" selected>Windows XP </option>
<option value="WindowsNT">WindowsNT </option>
</select>
</form></body>
</html>
<html>
<script language="javascript">
function openScript(url,name, width, height){
var Win = window.open(url,name,'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=yes' );
}
</script>
<body bgcolor="#ffffff">
<a href=# onclick="openScript('b.html','pur',300,250)" >设备类型</a>
原类型是Windows XP<br>
<span id="s"></span>
</body>
</html>b.html
<html>
<head>
<title>title</title>
<SCRIPT LANGUAGE=javascript>
function save(){
var v=document.theForm.type.value;
window.opener.document.getElementById('s').innerHTML=v;
window.close();
}
</script>
</head>
<body>
<form name="theForm">
<tr><td>
<select name="type">
<option value="Unix">Unix </option>
<option value="Unknown">Unknown </option>
<option value="Windows 2000">Windows 2000 </option>
<option value="Windows 2003">Windows 2003 </option>
<option value="Windows 98">Windows 98 </option>
<option value="Windows XP" selected>Windows XP </option>
<option value="WindowsNT">WindowsNT </option>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="store" value="保存" onClick="save()">
<input type="reset" name="reset" value="取消" onclick="window.close()">
</form>
</td>
</tr>
</body>
</html>
<html>
<script language="javascript">
function openScript(url,name, width, height){
var Win = window.open(url,name,'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=yes' );
}
</script>
<body bgcolor="#ffffff">
<% String sType = request.getParameter("type");
if(sType.epuals("window 2000")){
out.print("类型是window 2000")
}
if(sType.epuals("window XP")){
out.print("类型是window XP")
}
if(sType.epuals("window 98")){
out.print("类型是window 98")
}
if(sType.epuals("unix")){
out.print("类型是unix")
}
%>
<a href=# onclick="openScript('b.html','pur',300,250)" >设备类型</a>
</body>
</html>b.jsp
<html>
<head>
<title>title</title>
<SCRIPT LANGUAGE=javascript>
function save(){
var v=document.theForm.type.value;
window.opener.document.getElementById('s').innerHTML=v;
window.close();
}
</script>
</head>
<body>
<form name="theForm">
<tr><td>
<select name="type">
<option value="Unix">Unix </option>
<option value="Unknown">Unknown </option>
<option value="Windows 2000">Windows 2000 </option>
<option value="Windows 2003">Windows 2003 </option>
<option value="Windows 98">Windows 98 </option>
<option value="Windows XP">Windows XP </option>
<option value="WindowsNT">WindowsNT </option>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="store" value="保存" onClick="save()">
<input type="reset" name="reset" value="取消" onclick="window.close()">
</form>
</td>
</tr>
</body>
</html>
小弟的意思是:a.jsp中获取的sType如何在b.jsp中得到相应的显示?即如果sType==Windows XP,如何在b.jsp的下拉列表框就默认显示Windows XP???同时在b.jsp中修改如何在a.jsp中动态显示出来?即如果在b.jsp中改为unix,点保存后如何让a.jsp刷新显示"类型是unix"?????
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="javascript">
function openScript(url,name, width, height){
var param="?sType="+document.form.stype.value;
var Win = window.open(url+param,name,'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=yes');
}
</script>
</head>
<body bgcolor="#ffffff">
<% String sType = request.getParameter("type");
if(sType==null)sType="windows 2000";
if(sType.equals("windows 2000")){
sType="windows 2000";
}
if(sType.equals("windows XP")){
sType="window XP";
}
if(sType.equals("windows 98")){
sType="windows 98";
}
if(sType.equals("unix")){
sType="unix";
}
%>
<a href=# onclick="openScript('b.jsp','pur',300,250)" >设备类型</a><br/>
<span id="s">类型是<%=sType%></span>
<form name="form">
<input type="hidden" value="<%=sType%>" name="stype"/>
</form>
</body>
</html>
b.jsp<html>
<head>
<title>title</title>
<SCRIPT LANGUAGE=javascript>
function save(){
var v=document.theForm.type.value;
window.opener.document.getElementById('s').innerHTML=v;
window.opener.document.form.stype.value=v;
window.close();
}
window.onload=function(){
initSelectWithValue(document.theForm.type,'<%=request.getParameter("s")%>');
}
function initSelectWithValue(selectObj,oldValue){
for(var i=0;i<selectObj.length;i++){
if(selectObj.options[i].value == oldValue){
selectObj.options[i].selected = true;
break;
}
}
}
</script></head>
<body>
<form name="theForm">
<tr><td>
<select name="type">
<option value="unix">Unix </option>
<option value="unknown">Unknown </option>
<option value="windows 2000">Windows 2000 </option>
<option value="windows 2003">Windows 2003 </option>
<option value="windows 98">Windows 98</option>
<option value="windows XP">Windows XP </option>
<option value="windowsNT">WindowsNT </option>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" name="store" value="保存" onClick="save()">
<input type="reset" name="reset" value="取消" onclick="window.close()">
</form>
</td>
</tr>
</body>
</html>
小弟佩服,感谢!!!
试过你的代码,基本实现我说的功能,不过还有个小问题:a.jsp中获取的sType没有在b.jsp中得到相应的显示,即如果a.jsp中获取的sType==Windows XP,如何在b.jsp的下拉列表框就默认显示Windows XP???现在试不管sType是什么,b.jsp的下拉列表框默认显示unix
鄙人笨,望大哥再修改一下,不甚感激!!!!!!谢谢了~~~~
为什么b.jsp的下拉列表框默认显示unix,而不是a.jsp中的sType值???
为什么b.jsp的下拉列表框默认显示unix,而不是a.jsp中的sType值???
鄙人笨,望大哥再修改一下,不甚感激!!!!!!谢谢了~~~~
搞定马上结散分,再次谢谢了
问题一:
看b.jsp编译后的html代码,
看这段代码---》initSelectWithValue(document.theForm.type,'<%=request.getParameter("s")%>');<%=request.getParameter("s")%>的值和下拉框的值是否一样,比如空格,大小写等等
问题搞定了
麻烦你了,不甚感激!!!!!!谢谢了~~~~