I am trying to open a new popup window, insert values into database, after that return one value to current window. After I open a new popup window and click return, it returns the value but when I click on submit and return it after that, the value doesn’t get returned. I think that’s because the new window gets refreshed by the submit button. That’s why it doesn’t return the value.
Main Page
<form></form>
<form>
<input name="maparea" size="2" type="TEXT">
<input onclick='targetitem = document.forms[1].maparea; dataitem = window.open("popup.php", "dataitem", "toolbar=no,menubar=no,scrollbars=yes"); dataitem.targetitem = targetitem' value="Get Value" type="button">
</form>
Popoup window
<script>
function select_item(item){
targetitem.value = item;
top.close();
return false;
}
</script>
<form action="" method="post">
<input type="submit" name="sub" value="Submit" />
<input type="button" name="re" value="Return" onclick='return select_item("3")' />
</form>
Any solution for that?
I want to submit what I want first after that return the value
In the popup, hook an onclick event on your submit button so it executes before the submit.
Then in the onclick handler do:
Then after the submit, your parent window will have that value, and you can access it like this: