I'm trying to pass form input data to an asp email script. The input data isn't be captured by the asp code. I would really appreciate any help you can give. I have included both the from code and the asp code. For testing purposes, I have commented out all email code. Please review my Response.Write section which will not write any of the variables. Thanks so much for your suggestions and time.
Form htm:
<html>
<head>
<LINK href="style.css" rel=stylesheet>
<script LANGUAGE="JavaScript"><!--
//-->
<!-- This script and many more are available online from -->
<!-- The JavaScript Source!!
http://javascriptsource.com -->
<!-- Begin
function getCookie(name){
var cname = name + "=";
var dc = document.cookie;
if (dc.length > 0) {
begin = dc.indexOf(cname);
if (begin != -1) {
begin += cname.length;
end = dc.indexOf(";", begin);
if (end == -1) end = dc.length;
return unescape(dc.substring(begin, end));
}
}
return "";
}
function setCookie(name, value, expires) {
document.cookie = name + "=" + escape(value) +
((expires != null) ? "; expires=" + expires.toGMTString() : "")
+ "; path=/";
}
function setName() {
var expdate = new Date ();
expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000 * 365));
var prompt=i = document.Mail.name.value;
setCookie("name", i, expdate);
}
function getName() {
if(getCookie("name") != null) {
document.Mail.Name.value = getCookie("emailname");
}
}
function getInfo() {
var now= new Date();
document.Mail.Info.value = "Browser: " + navigator.userAgent;
document.Mail.Info.value += "Date:" + now;
}
function checkMultiple() {
if (getCookie("emailsent") == 'true') return true;
else return false;
}
function process() {
setCookie("emailsent", "true");
with (document.Mail) {
if (Subject.selectedIndex == 1) action = "email_send.asp";
else if (Subject.selectedIndex == 2) action = "email_send.asp";
else if (Subject.selectedIndex == 3) action = "email_send.asp";
else if (Subject.selectedIndex == 4) action = "email_send.asp";
else if (Subject.selectedIndex == 5) action = "email_send.asp";
else action = "email_send.asp";
}
}
function formCheck() {
var passed = false;
with (document.Mail) {
if (Name.value == "") {
alert("Please inlcude your name.");
Name.focus();
}
else if (Subject.selectedIndex == 0) {
alert("Please pick a subject.");
Subject.focus();
}
else if (checkMultiple()) {
if (confirm("You just sent an e-mail from this form, are you sure you want to send another?")) {
process();
passed = true;
}
}
else {
process();
passed = true;
}
}
return passed;
}
// End -->
</script>
<title>Madison Township Contact Form</title>
<base target="mainFrame">
</head>
<body BGCOLOR="#9E9E9E" link="#CC0033" vlink="#333399" alink="#FF0000"
<!--content start-->
<p align="center"></p>
<table WIDTH="100%" BORDER="1" CELLSPACING="0" CELLPADDING="0">
<tr>
<td WIDTH="100%"><P align="center"><font FACE="Times" SIZE="5" Color="#CC0000"> Madison Township Comment Form<BR>
<font FACE="ARIEL,HELVETICA" SIZE="1">
<font FACE="Times" SIZE="2" Color="white">Have something you would like to tell us? Any
comments, suggestions, or questions?
<%Dim mail
%>
<form METHOD="POST" NAME="Mail" ACTION="email_send.asp"
ENCTYPE="text/plain" onSubmit="return formCheck();">
<input type="hidden" name="Info" value>
<table BORDER="0" CELLPADDING="5" CELLSPACING="0">
<tr>
<td><font FACE="ARIEL,HELVETICA" SIZE="2"> Name: <input TYPE="text" NAME="Name" onChange="setName()" size="25">
</td>
<td ALIGN="LEFT"><font FACE="ARIEL,HELVETICA" SIZE="2">Subject: <select NAME="Subject" size="1" >
<option SELECT><font FACE="ARIEL,HELVETICA" SIZE="1">Select a subject</option>
<option><font FACE="ARIEL,HELVETICA" SIZE="1">1) Comment</option>
<option><font FACE="ARIEL,HELVETICA" SIZE="1">2) Question</option>
<option><font FACE="ARIEL,HELVETICA" SIZE="1">3) Suggestion</option>
<option><font FACE="ARIEL,HELVETICA" SIZE="1">4) Miscellaneous</option>
<option><font FACE="ARIEL,HELVETICA" SIZE="1">5) Website</option>
</select>
</td>
</tr>
<tr>
<td><font FACE="ARIEL,HELVETICA" SIZE="2">Address: <input TYPE="text" NAME="Address" onChange="setName()" size="35"><BR>
<font FACE="ARIEL,HELVETICA" SIZE="2">City: <input TYPE="text" NAME="City" onChange="setName()" size="16">
<font FACE="ARIEL,HELVETICA" SIZE="2">State: <input TYPE="text" NAME="State" onChange="setName()" size="2">
<font FACE="ARIEL,HELVETICA" SIZE="2">Zip: <input TYPE="text" NAME="Zip Code" onChange="setName()" size="8"><BR>
<font FACE="ARIEL,HELVETICA" SIZE="2">Phone Number: <input TYPE="text" NAME="Phone" onChange="setName()" size="15">
<font FACE="ARIEL,HELVETICA" SIZE="2">Email: <input TYPE="text" NAME="email" onChange="setName()" size="45">
<BR><BR><font FACE="ARIEL,HELVETICA" SIZE="2">Would you like someone to contact you?
<INPUT TYPE="radio" NAME="Contact Me" VALUE="Yes">Yes
<INPUT TYPE="radio" NAME="Contact Me" VALUE="No">No
</td>
</tr>
<tr>
<td COLSPAN="2"><font FACE="ARIEL,HELVETICA" SIZE="2">Comments, questions, suggestions, anything!: <BR>
<textarea NAME="Comment" COLS="50" ROWS="4"></textarea>
</td>
</tr>
</table>
<div align="center"><center>
<table>
<tr>
<td align="center">
<input TYPE="submit" VALUE="Send Email">
<Input TYPE="Reset" VALUE="Clear Form">
<script LANGUAGE="JavaScript">
<!-- Begin
getInfo();
getName();
// End -->
</script></font></font></td>
</tr>
</table>
</center></div>
</form>
</td>
</tr>
</table>
<!--content stop-->
</body>
</html>
************************************************** *************
email_send.asp
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
</HEAD>
<BODY bgcolor="#808080">
<font size="4" face="Tahoma" color="#FFFFFF">
<%
'Sends an email
Dim mail
Set mail = Server.CreateObject("CDO.Message")
'mail.To = "
gclarkox@direcway.com"
'mail.From = Request.Form("email")
'mail.Subject = "Website Email - contact may have been requested"
'mail.HTMLBody ="<h5>Name: </h5>" & Request.Form("name") & "<h5>Subject Selected: </h5>" & Request.Form("subject") & "<h5>Address: </h5>" & Request.Form("address") & "<h5>City: </h5>" & Request.Form("city") & "<h5>State: </h5>" & Request.Form("state") & "<h5>Zip Code: </h5>" & Request.Form("zip code") & "<h5>Contact Me: </h5>" & Request.Form("contact me") & "<h5>Phone #: </h5>" & Request.Form("phone") & "<h5>Question, Request, Comment or Suggestion: </h5>" & Request.Form("comment")
'mail.Send()
Response.Write("Your question, request, comment or suggestion has been sent!")
Response.write("<BR>" & vbNewline)
Response.Write("Your message was: ")
Response.write("<BR>" & vbNewline)
Response.Write(Request.Form("comment"))
Response.Write("Your email address is: ")
Response.write("<BR>" & vbNewline)
Response.Write(Request.Form("email"))
'Destroy the mail object!
Set mail = nothing
%>
<%
' Note that I'm using the Win2000 CDO syntax! I'm
' assuming most people are off of NT4 by now.
' For simplicity and because I'm not letting you enter
' them, I'm not validating email addresses. If you let
' people enter them you should at least do some
' rudimentary level of validation to ensure entries
' are valid.
Dim objMessage
Set objMessage = Server.CreateObject("CDO.Message")
'With objMessage
' Set message attributes
' .To = Request.Form("email")
' .From = "Gene Clark<
gclarkox@direcway.com>"
'.From = "Madison Township Trustees <
trustees@MadisonTownshipOH.net>"
' .Subject = "Thank you from the Madison Township Trustees"
'.TextBody = "We appreciate you taking the time to contact us. We have received your question, request, comment or suggestion. If you requested to be contacted, one of the township trustees will contact you as soon as possible."
'.CreateMHTMLBody "http://"
' Attachment using known static physical path
'.AddAttachment "c:\somepath\somefile.txt"
' Attachment using mappath to find the physical path
'.AddAttachment Server.MapPath("images/asp101-100x30.gif")
' Attachment added directly from a URL
'.AddAttachment "
http://www.asp101.com/samples/images/asp101-100x30.gif"
' Send message - uncomment the following line only
' AFTER you've entered appropriate To and From
' addresses above. Then the script will actually
' send the messages.
' .Send
'End With
Set objMessage = Nothing
%>
</BODY>
</HTML>