Jump to content

Mail form script Alert - error


woodywyatt

Recommended Posts

I’m trying to get the JavaScript Alert to pop up on this mail form script but it just displays a blank page. It submits the form contents fine when the correct spam code is entered.Can anyone tell me what I need to change in the code in order for the JavaScript Alert to pop work?Actual form is here just in case you need to see it in action - rockislandbar.com/formtest.html

 

 

<% ' Define the used variables Dim verCode ' Retrieve the form data verCode = Request.Form("verCode") ' Check if the entered code is the actual code If isCode(verCode) then If Request.Form("submit") <> "" ThenSet myMail=CreateObject("CDO.Message")myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.myhost.co.uk"myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 0myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = ""myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = ""myMail.Configuration.Fields.UpdatemyMail.Subject= "Contact Us From Website" 'This is the subject of the e-mailmyMail.To="my email@mysite.com" 'This is the e-mail address the e-mail will be delivered tomyMail.From=Request.Form("emaddress")myMail.TextBody="Name: " & Request.Form("name") & vbnewline & "E-Mail Address: " & Request.Form("emaddress") & vbnewline & "Message: " & Request.Form("message")myMail.Sendset myMail=nothingResponse.Redirect("thankyou.asp")Else 'Error output%><script language="javascript"><!--window.alert ("It looks like you entered the wrong code rnTry again or click 'Reload for another image' under the image.");window.history.go(-1);//--></script><% End If %> <% ' Function to check if the sent code is the actual verification code Function isCode(enteredCode) ' Check if the entered code in caps is same as the session code (which is in caps) if UCase(enteredCode) = Session("image_ver") then ' Return true isCode = true else 'Return False isCode = false end if End Function End If%>

Link to comment
Share on other sites

First, I would remove the HTML comments from the Javascript code (unless you're worried about how Netscape 1 or IE 2 will react). Second, use your browser's developer console to check for Javascript error messages on the page. Is that script tag the only thing the page outputs or is there a complete HTML document there?

Link to comment
Share on other sites

The script tag is the only thing that outputs the error alert. I did have it working fine until I was told by my hosting company to upgrade to Windows 2008 server. The only thing that changed was the send mail code from cdonts to cdosys.

Link to comment
Share on other sites

No worries, I've fixed it. Moved the Javascript code down to the end of the code:<% ' Function to check if the sent code is the actual verification code Function isCode(enteredCode) ' Check if the entered code in caps is same as the session code (which is in caps) if UCase(enteredCode) = Session("image_ver") then ' Return true isCode = true else %><script language="javascript"> <!-- window.alert ("It looks like you entered the wrong code rnTry again or click 'Reload for another image' under the image."); window.history.go(-1); //--> </script><% 'Return False isCode = false end if End Function End If%>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...