本文发表在 rolia.net 枫下论坛parent.jsp
<head>
<script language="javascript">
function showPopup() {
window.open("popup.jsp"); //why not html, You must have a reason :)
}
</script>
</head>
<body>
<br>
<h3> Staff Information </h3>
<table border=1>
<tr><td colspan=2> </td></tr>
<tr>
<td>Name: <input type="text" size=20 name="staff_name" value="Xiao Xiao"></td>
<td>Id: <input type="text" size=20 name="staff_id" value="1"></td>
</tr>
<tr>
<td>Name: <input type="text" size=20 name="staff_name" value="Da Da"</td>
<td>Id: <input type="text" size=20 name="staff_id" value="2"></td>
</tr>
<tr><td colspan=2 align="center"><input type=button value="Popup" onclick="javascript:showPo
pup()"></td></tr>
</table>
</body>
</html>
popup.jsp
<html>
<head>
<title>Popup Window</title>
<script language=javascript>
function getData(){
var allStaffName = window.opener.document.getElementsByName("staff_name");
var allStaffId = window.opener.document.getElementsByName("staff_id");
for(i=0; i<allStaffName.length && i<allStaffId.length; i++)
document.write("<option value=" + allStaffId[i].value + ">" + allStaffName[i].value + "</opt
ion>");
}
</script>
</head>
<body>
<select name="staffs">
<option value=0>Staff List</option>
<script>javascript:getData()</script>
</select>
</body>
</html>更多精彩文章及讨论,请光临枫下论坛 rolia.net
<head>
<script language="javascript">
function showPopup() {
window.open("popup.jsp"); //why not html, You must have a reason :)
}
</script>
</head>
<body>
<br>
<h3> Staff Information </h3>
<table border=1>
<tr><td colspan=2> </td></tr>
<tr>
<td>Name: <input type="text" size=20 name="staff_name" value="Xiao Xiao"></td>
<td>Id: <input type="text" size=20 name="staff_id" value="1"></td>
</tr>
<tr>
<td>Name: <input type="text" size=20 name="staff_name" value="Da Da"</td>
<td>Id: <input type="text" size=20 name="staff_id" value="2"></td>
</tr>
<tr><td colspan=2 align="center"><input type=button value="Popup" onclick="javascript:showPo
pup()"></td></tr>
</table>
</body>
</html>
popup.jsp
<html>
<head>
<title>Popup Window</title>
<script language=javascript>
function getData(){
var allStaffName = window.opener.document.getElementsByName("staff_name");
var allStaffId = window.opener.document.getElementsByName("staff_id");
for(i=0; i<allStaffName.length && i<allStaffId.length; i++)
document.write("<option value=" + allStaffId[i].value + ">" + allStaffName[i].value + "</opt
ion>");
}
</script>
</head>
<body>
<select name="staffs">
<option value=0>Staff List</option>
<script>javascript:getData()</script>
</select>
</body>
</html>更多精彩文章及讨论,请光临枫下论坛 rolia.net