I have created a frameset, in which one of its frames open a pop-up using window.open . In that window opened i have a form to collect input from users. Input which i'm trying to return to the parent but failing to. Any help. I tried using window.opener using this solution :Popup window to return data to parent on close but failed to get the getChoice() outcome back to the parent page.
The frame:
<form>
<button type="button" id="opener" onClick="lapOptionWindow('form.html','', '400','200');">Opinion </button>
</form>
the frame js:
function lapOptionWindow(url, title, w, h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
return window.open(url, title,'toolbar=no,location=no,directories=no, status=no, menubar=no, scrollbars=no,resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
}
form.html (the window opened):
<div id="lightbox">
<strong>Chinese/Portuguese: Chinese<input type="radio" name="chorpor" value="" id="choice1"> Portuguese<input type="radio" name="chororpor" value="" id="choice2"></strong>
</br><button type="button" id="food" onclick="getChoice()">Submit</button>
</div>
form.js:
function getChoice() {
var choice = "";
var choice1 = document.getElementById("choice1 ");
choice = choice1.checked == true ? "Chinese" : "Portuguese";
return choice;
}
See Question&Answers more detail:os