bikebanditcom
Programmer
can any one help? im trying to get my page to email form results to me, however i can't get it to work the following two pages are used to proceess the form..
the html form
<HTML>
<HEAD>
<SCRIPT LANGUAGE=JavaScript>
<!--
function DoctorElements()
{
var i,j;
for (i=0; i < document.forms[0].elements.length-1; i++)
switch (String(document.forms[0].elements.name).substring(0,3))
{
case "chk":
if (document.forms[0].elements.checked)
document.forms[0].elements.value = "Yes";
else {
document.forms[0].elements.checked = true;
document.forms[0].elements.value = "No";
}
break;
}
}
// -->
</SCRIPT>
</HEAD>
<BODY>
<FORM METHOD=POST ACTION="mailForm.asp" ONSUBMIT="DoctorElements();">
<INPUT TYPE=HIDDEN NAME="urlSendTo" VALUE="thankyou.htm">
<INPUT TYPE=HIDDEN NAME="urlFromPath" VALUE="default.htm">
Name: <INPUT TYPE=TEXT NAME="txtUser.Name"><BR>
Age:
<SELECT NAME=selUser.Age SIZE=1>
<OPTION VALUE="Under 18">Under 18</OPTION>
<OPTION VALUE="18 - 24">18 - 24</OPTION>
<OPTION VALUE="25 - 40">25 - 40</OPTION>
<OPTION VALUE="Over 40">Over 40</OPTION>
</SELECT><BR>
Sex:
<BR>
<INPUT TYPE=RADIO NAME=radSex VALUE="Male" CHECKED>Male<BR>
<INPUT TYPE=RADIO NAME=radSex VALUE="Female">Female
<P>
I like cheese: <INPUT TYPE=CHECKBOX NAME=chkI.Like.Cheese>
<P><INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>
the asp script
<%@ Language=VBScript %>
<% Option Explicit %>
<%
'The header/footer for the email.
Const strHeader = "Here are the results of the form:"
Const strFooter = "Form mailer created by 4GuysFromRolla.com, 1999"
'Who does this go to? MAKE SURE TO CHANGE THIS TO YOUR EMAIL ADDRESS!
Const strTo = "danhaydenjr@hotmail.com"
'This information is optional
Dim strFrom, strSubject, strRedirectURL, strFromPath
strFrom = Request.Form("txtSendToEmailAddress"
if Len(strFrom) = 0 then strFrom = strTo
strSubject = Request.Form("txtEmailSubject"
if Len(strSubject) = 0 then strSubject = "FORM EMAILER: 4GuysFromRolla.com"
strRedirectURL = Request.Form("urlSendTo"
if Len(strRedirectURL) = 0 then strRedirectURL = "/"
strFromPath = Request.Form("urlFromPath"
if Len(strFromPath) = 0 then strFromPath = "UNKNOWN"
Dim strBody
strBody = strHeader & ( vbCrLf & vbCrLf )
strBody = strBody & ( "FORM: " & strFromPath & vbCrLf ) & _
( "FORM submitted at " & Now() & vbCrLf & vbCrLf )
dim ix, formElementName, formElementValue, prefix, fldName
For ix = 1 to Request.Form.Count
formElementName = Request.Form.Key(ix)
formElementValue = Request.Form.Item(ix)
' what type of field was that on the form?
prefix = Left(formElementName,3)
' and throw away prefix to get actual field name
fldName = Mid(formElementName,4)
' but change periods to spaces for readability
fldName = Replace(fldName, "."," "
Select Case prefix
' if the prefix indicates this is a form field of interest...
Case "txt","sel","rad","cbo","lst","chk":
' if user didn't answer this question, say so...
if Len(formElementValue) = 0 then formElementValue = "UNANSWERED"
' then tack on the name of the field and the answer
strBody = strBody & (fldName & ": " & formElementValue & vbCrLf)
End Select
Next
strBody = strBody & ( vbCrLf & strFooter )
'Time to send the email
Dim objCDO
Set objCDO = Server.CreateObject("CDONTS.NewMail"
objCDO.To = strTo
objCDO.From = strFrom
objCDO.Subject = strSubject
objCDO.Body = strBody
objCDO.Send
Set objCDO = Nothing
'Send them to the page specified
Response.Redirect strRedirectURL
%>
i get a page cannot be displayed after putting it up on a server that is an NT box...any ideas why or does anyone have any better idea of how to do this? Thanks alot
dan
the html form
<HTML>
<HEAD>
<SCRIPT LANGUAGE=JavaScript>
<!--
function DoctorElements()
{
var i,j;
for (i=0; i < document.forms[0].elements.length-1; i++)
switch (String(document.forms[0].elements.name).substring(0,3))
{
case "chk":
if (document.forms[0].elements.checked)
document.forms[0].elements.value = "Yes";
else {
document.forms[0].elements.checked = true;
document.forms[0].elements.value = "No";
}
break;
}
}
// -->
</SCRIPT>
</HEAD>
<BODY>
<FORM METHOD=POST ACTION="mailForm.asp" ONSUBMIT="DoctorElements();">
<INPUT TYPE=HIDDEN NAME="urlSendTo" VALUE="thankyou.htm">
<INPUT TYPE=HIDDEN NAME="urlFromPath" VALUE="default.htm">
Name: <INPUT TYPE=TEXT NAME="txtUser.Name"><BR>
Age:
<SELECT NAME=selUser.Age SIZE=1>
<OPTION VALUE="Under 18">Under 18</OPTION>
<OPTION VALUE="18 - 24">18 - 24</OPTION>
<OPTION VALUE="25 - 40">25 - 40</OPTION>
<OPTION VALUE="Over 40">Over 40</OPTION>
</SELECT><BR>
Sex:
<BR>
<INPUT TYPE=RADIO NAME=radSex VALUE="Male" CHECKED>Male<BR>
<INPUT TYPE=RADIO NAME=radSex VALUE="Female">Female
<P>
I like cheese: <INPUT TYPE=CHECKBOX NAME=chkI.Like.Cheese>
<P><INPUT TYPE=SUBMIT>
</FORM>
</BODY>
</HTML>
the asp script
<%@ Language=VBScript %>
<% Option Explicit %>
<%
'The header/footer for the email.
Const strHeader = "Here are the results of the form:"
Const strFooter = "Form mailer created by 4GuysFromRolla.com, 1999"
'Who does this go to? MAKE SURE TO CHANGE THIS TO YOUR EMAIL ADDRESS!
Const strTo = "danhaydenjr@hotmail.com"
'This information is optional
Dim strFrom, strSubject, strRedirectURL, strFromPath
strFrom = Request.Form("txtSendToEmailAddress"
if Len(strFrom) = 0 then strFrom = strTo
strSubject = Request.Form("txtEmailSubject"
if Len(strSubject) = 0 then strSubject = "FORM EMAILER: 4GuysFromRolla.com"
strRedirectURL = Request.Form("urlSendTo"
if Len(strRedirectURL) = 0 then strRedirectURL = "/"
strFromPath = Request.Form("urlFromPath"
if Len(strFromPath) = 0 then strFromPath = "UNKNOWN"
Dim strBody
strBody = strHeader & ( vbCrLf & vbCrLf )
strBody = strBody & ( "FORM: " & strFromPath & vbCrLf ) & _
( "FORM submitted at " & Now() & vbCrLf & vbCrLf )
dim ix, formElementName, formElementValue, prefix, fldName
For ix = 1 to Request.Form.Count
formElementName = Request.Form.Key(ix)
formElementValue = Request.Form.Item(ix)
' what type of field was that on the form?
prefix = Left(formElementName,3)
' and throw away prefix to get actual field name
fldName = Mid(formElementName,4)
' but change periods to spaces for readability
fldName = Replace(fldName, "."," "
Select Case prefix
' if the prefix indicates this is a form field of interest...
Case "txt","sel","rad","cbo","lst","chk":
' if user didn't answer this question, say so...
if Len(formElementValue) = 0 then formElementValue = "UNANSWERED"
' then tack on the name of the field and the answer
strBody = strBody & (fldName & ": " & formElementValue & vbCrLf)
End Select
Next
strBody = strBody & ( vbCrLf & strFooter )
'Time to send the email
Dim objCDO
Set objCDO = Server.CreateObject("CDONTS.NewMail"
objCDO.To = strTo
objCDO.From = strFrom
objCDO.Subject = strSubject
objCDO.Body = strBody
objCDO.Send
Set objCDO = Nothing
'Send them to the page specified
Response.Redirect strRedirectURL
%>
i get a page cannot be displayed after putting it up on a server that is an NT box...any ideas why or does anyone have any better idea of how to do this? Thanks alot
dan