Click to See Complete Forum and Search --> : Closing Pop Window


ejrhodes
05-14-2003, 06:58 PM
Guys,

In my ASP page, I popup a child window that contains a form. This form posts to itself in the pop-up window. After the form is submitted, processed and the page loads, I want to close the popup window.

The code for the asp page that the pop-up window calls is as follows:

<html>
<head>
</head>

<%

If request.form("action")="addemail" Then%>
<!--#include file="dsn.asp"-->
<%
sql="Update members set email='" & request.form("email") & "' where fullname='" & session("Name") & "'"
response.write(sql)
'set RS=conn.execute(sql)
'RS.Close
'Set RS=Nothing
response.write "Thanks"
%>
<body Onload="javascript:self.close;">
<%
Else
%>


<body>
In an effort to add more functionality to time tracker, please enter your email address in the form below. You will not be prompted for this again.
<form method="POST" action="emailform.asp" name="Email_Form">
User Name: <%=session("Name") %> <br>
Email Address: <input type="text box" name="email" size="30"><br>
<input type="hidden" name="action" value="addemail">
<input type="Submit" value="Thanks">
</form>
<%End If%>
</body>
</html>


What am I doin wrong with the onload command? Thanks

khalidali63
05-14-2003, 07:04 PM
Remove this line from your code

<body Onload="java script:self.close;">

and add self.close to the onsubmit event of the form element

ejrhodes
05-14-2003, 07:19 PM
Originally posted by khalidali63
Remove this line from your code

<body Onload="java script:self.close;">

and add self.close to the onsubmit event of the form element

Here is my new code <html>
<head>
</head>
<%
If request.form("action")="addemail" Then%>
<!--#include file="dsn.asp"-->
<%
sql="Update members set email='" & request.form("email") & "' where fullname='" & session("Name") & "'"
response.write(sql)
set RS=conn.execute(sql)
RS.Close
Set RS=Nothing
Else
%>

<body>
In an effort to add more functionality to time tracker, please enter your email address in the form below. You will not be prompted for this again.
<form method="POST" onSubmit="self.close();" action="emailform.asp" name="Email_Form">
User Name: <%=session("Name") %> <br>
Email Address: <input type="text box" name="email" size="30"><br>
<input type="hidden" name="action" value="addemail">
<input type="Submit" value="Thanks">
</form>
<%End If%>
</body>
</html>

</html>


The problem with putting the close on the on submit is the page does not process the form. It simply closes the window after I click submit. Since i am processing it in the same window, dont I need to close it after the form loads?

ejrhodes
05-14-2003, 07:24 PM
I added the self.close() on the onLoad and it worked fine now. It closed the window after I processed the form. Thanks for pointing me in the correct direction