ASP Script Opens New Window!

R

Robert Atkinson

I am quite new to ASP and trying to find my feet!

I've cobbled together some code to email some form data which works
fine, but when I try to write a success message back to the browser,
or use response.redirect, my browser opens a new window instead of
writing to the current window.

Is there something I can do to stop this? My code is pasted below.

Many thanks, Robert.


MAILFORM.HTM

<form method="POST" action="contactus.asp">
<table border="0" width="100%">
<tr>
<td width="24%">Your Name</td>
<td width="42%"><input type="text" name="Name" size="37"></td>
</tr>
<tr>
<td width="66%" valign="top" colspan="2">Message<br>
<textarea rows="4" name="Message" cols="52"></textarea></td>
</tr>
</table>
<table border="0" width="40%">
<tr>
<td width="33%" align="center"><input type="submit"
value="Send" name="B1"></td>
<td width="33%" align="center"><input type="reset"
value="Reset" name="B2"></td>
<td width="34%" align="center"><input type="button"
value="Cancel" name="B3" onclick='self.close()'></td>
</tr>
</table>
</form>



CONTACTUS.ASP

<%
smtp_server_address = "localhost"
on error resume next
response.buffer = true
Set Jmail = Server.CreateOBject( "JMail.Message" )
Jmail.Logging = true
Jmail.Silent = true
JMail.From = "C&NEE_Contact_Us"
Jmail.AddRecipient "(e-mail address removed)"
JMail.Subject = "Information Request"
FOR EACH el IN Request.Form
body = body & el & ": " & Request.form(el) & vbcrlf
NEXT
JMail.Body = Body
JMail.Priority = 1
if not Jmail.Send(smtp_server_address) then
' There was an error - print the error log
Response.write ("Error:<br>" & Jmail.log)
else
' The message has been sent - redirect to confirmation page
Set JMail = Nothing
response.write ("<script>document.write('Your message has been
sent');</script>")
end if
Set JMail = Nothing
%>
 
C

Curt_C [MVP]

why are you using a Response.Write to write a <script> with document.write?
Why not just use the Response.Write ?
Your problem isn't the Response.Write by the way, it's the client-side
<script> tag that's opening the new window
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top