开发者

asp form question

开发者 https://www.devze.com 2023-01-07 13:35 出处:网络
I have this form <form action=\"http://www.mysite.com/asp/formd.asp\" method=\"post\" target=\"_blank\">

I have this form

<form action="http://www.mysite.com/asp/formd.asp" method="post" target="_blank">

so the asp looks like below,

it opens a new window where ot says "send ok"

my question is how and where can I contro/define the style of this new window i.e background fonts color etc thanks

the ASP code:

<%@ Language=VBScript %>

<%

Dim txtbody
D开发者_如何学Cim objCDO
Set objCDO = Server.CreateObject("CDONTS.NewMail")

objCDO.To = "mail@mail.com"
objCDO.From = "digital@adinet.com"
objCDO.Subject = "* *Formu enviado desde web * *"

txtbody = ""
for a = 1 to Request.Form.Count
 txtbody = txtbody & Request.Form.Key(a) & " = " & Request.Form(a) & chr(10) & chr(13)
next

for a = 1 to Request.QueryString.Count
 txtbody = txtbody & Request.QueryString.Key(a) & " = " & Request.QueryString(a) & chr(10) & chr(13)
next

txtbody = txtbody & "*******-----------------******"

objCDO.Body = txtbody

objCDO.Send

Response.Write "send = Ok"

%>


If you'd like to have a page or message that's more meaningful, consider replacing this

Response.Write "send = Ok"

with this:

Response.Redirect "email-thank-you.htm" 'or .asp, whatever you like.

Then go make your new page email-thank-you.htm as decorated and styled as nicely as you can. This helps by having your email logic contained in one page or function, and separate from the nice page. If something happened, i.e. the email server was unavailable, or perhaps the email address was malformed/missing, you could write that back to the original page.


If I understand what you're doing correctly, you should actually create a static form called emailForm.asp with your desired styling. Have it read the querystring that you are passing and and place the values in the fields. Put on link on your current page in order to pop this page up.


Your final line, Response.Write "send = Ok" is being output as a badly-formed html page.

I'd recommend you structure your page as follows:

<%@ Language=VBScript %>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
 <!-- Add header info, including links to style sheets -->
</head>
<body>
<%
'Your CDO code goes here

  objCDO.Send

  if err.number > 0 then
    response.write "<p class='error'>Error: " & err.number & " - " & err.message & "</p>"
  else
    Response.write "<p class='ok'>Sent OK</p>"
  end if
%>
</body>
</html>

This will render a full html page that you can style properly (and will also no presume that the email sent OK!).

0

精彩评论

暂无评论...
验证码 换一张
取 消