/    Sign up×
Community /Pin to ProfileBookmark

Closing Pop Window

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:

[code=php] <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>
[/code]

What am I doin wrong with the onload command? Thanks

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@khalidali63May 15.2003 — Remove this line from your code

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

and add self.close to the onsubmit event of the form element
Copy linkTweet thisAlerts:
@ejrhodesauthorMay 15.2003 — [i]Originally posted by khalidali63 [/i]

[B]Remove this line from your code



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



and add self.close to the onsubmit event of the form element [/B]
[/QUOTE]


Here is my new code[code=php] <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>
[/code]


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?
Copy linkTweet thisAlerts:
@ejrhodesauthorMay 15.2003 — 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
×

Success!

Help @ejrhodes spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...