stigster
asked on
Sending information from one window to another
Is there possible to send information from one window to another, like submitting values from a form in a popup window to its parent, while closing the popup AND refreshing the parent window?
ASKER
Maybe I should have mentioned that I'm using a servlet in the 'action=' attribute field.
I want the popup window to send its info to the servlet AND close itself AND refresh the parent window.
Think of it as a forum, where you are able to reply to any post. By clicking 'reply', a popupwindow appears with reference to which post it is a reply to.
The problem emerges when submitting the new entry - the servlet cannot do a 'response.redirect("")' because that would redirect the popup window.
Instead I want it to .close() and refresh the window from which i was opened. I recon this is some javaScript trick, but I'm not very in to that :)
I want the popup window to send its info to the servlet AND close itself AND refresh the parent window.
Think of it as a forum, where you are able to reply to any post. By clicking 'reply', a popupwindow appears with reference to which post it is a reply to.
The problem emerges when submitting the new entry - the servlet cannot do a 'response.redirect("")' because that would redirect the popup window.
Instead I want it to .close() and refresh the window from which i was opened. I recon this is some javaScript trick, but I'm not very in to that :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
damn vbscript.... I have been working in stupid ASP for too long....
The last two lines of the servlet should read "out.println(...)" instead of "out.writeln(..)"
Sorry about that
The last two lines of the servlet should read "out.println(...)" instead of "out.writeln(..)"
Sorry about that
the last line should be window.opener instead of window.opner
Sorry again
Sorry again
The above can be achieved in the following way....suppose u opened up a popup..say "insertScreen.jsp" the action of this jsp is to insert.jsp
then in insert.jsp....u can carry on with the inserts to the database and then in insert.jsp use the following logic
<html>
<head>
<script language="Javascript">
function back()
{
window.history.back();
}
</script>
</head>
<body class="gpbody">
<table>
<tr>
<td >
<%
if(INSERT_FAILED){
out.println( "<span >Insert failed</span>" );%><br /><br /><%
}else {%>
<script language="Javascript">
window.opener.document.hea
window.close();
</script>
<%}%>
</td>
</tr>
<tr>
<td>
<form name=dummyform>
<input type="button" value="back" onClick="back()">
</form>
</td>
</tr>
</body>
</html>
I here assume that u have the parent window with some form named headerform....which is used to retrieve something from the database...even u don't have some logic like this....then u can use the logic of assigning the values to the parent window form elements...
like window.opener.document.for
Hope this helps
regards
fargo