Her er et eksempel, hvor et popupvindue med en form, sender alle felter tilbage til startsiden, i et JSON objekt.
Hovedside:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Popup and sendback</title>
<script type="text/javascript">
var popwin;
function receiveFromPopup(objReply) {
popwin.close();
var elm = document.getElementById("returnID");
for ( key in objReply ) {
elm.appendChild( document.createTextNode( key + ' = ' + objReply[key] ) );
elm.appendChild( document.createElement("br") );
}
}
function StartPopup() {
popwin = window.open( 'popup.html', '_blank', "height=200,width=300,status=no,toolbar=no,menubar=no,location=no");
}
</script>
</head>
<body>
<h3>Test value from popup</h3>
<div id="returnID" style="border: 2px solid gray; padding: 5px;"></div>
<p>
<input type="button" value="Open Popup" onclick="StartPopup()">
</p>
</body>
</html>
Popupside:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Popup and sendback</title>
<script type="text/javascript">
function sendFormBack() {
var reply = {
fullname: document.myForm.fullname.value,
message: document.myForm.message.value,
checkbox1: document.myForm.checkbox1.checked,
checkbox2: document.myForm.checkbox2.checked
}
opener.receiveFromPopup(reply);
}
</script>
</head>
<body style="padding: 50px;">
<form name="myForm" action="" onsubmit="sendFormBack(); return false;">
<input name="fullname" type="text" value="type your full name here" onfocus="this.select();"><br>
<input name="message" type="text" value="type your message here" onfocus="this.select();"><br>
CB1 <input name="checkbox1" type="checkbox" /><br>
CB2 <input name="checkbox2" type="checkbox" /><br>
<input type="submit" value="Send data back">
</form>
</body>
</html>
Du skal så bare skrive funktion receiveFromPopup om til at behandle de modtagne data, så det passer til din opgave.
Jeg er ikke sikker på, at jeg helt forstår hvad du vil, men hvis du har en form på hovedsiden kan du f.eks. skrive:
document.myForm.fullname.value = objReply.fullname;