An oversimplified example would be:
Parent.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv"Script-Content-Type" content="text/javascript">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Expires" content="0"> <!-- disable caching -->
<title>Parent</title>
<script type="text/javascript">
targetElement = null;
function makeSelection(frm, id) {
if(!frm || !id)
return;
targetElement = frm.elements[id];
var handle = window.open('Child.html');
}
</script>
</head>
<body>
<form id="frm" name="frm" action="#">
<span>Name: </span><input name="txtName" id="txtName">
<input type="button" value="Select Name" onclick="makeSelection(this.form, 'txtName');">
</form>
</body>
</html>
Child.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv"Script-Content-Type" content="text/javascript">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="Expires" content="0"> <!-- disable caching -->
<title>Example</title>
<script type="text/javascript">
function makeSelection(frm, id) {
if(!frm || !id)
return;
var elem = frm.elements[id];
if(!elem)
return;
var val = elem.options[elem.selectedIndex].value;
opener.targetElement.value = val;
this.close();
}
</script>
</head>
<body>
<form id="frm" name="frm" action="#">
<span>Names: </span>
<select name="nameSelection">
<option value="holly">Holly</option>
<option value="golly">Golly</option>
<option value="molly">Molly</option>
</select>
<input type="button" value="Select Name" onclick="makeSelection(this.form, 'nameSelection');">
</form>
</body>
</html>
The code in itself is self explanatory but feel free to ask for explanations.
Super Moderator
Featured Poster
Reputation Points: 3233
Solved Threads: 720
Failure as a human
Offline 8,872 posts
since Jun 2006