I'm building a dynamic form with radio buttons. These radio buttons will hold values that have specific email addresses of respective people in a company.
here is the html and asp code shown below:
<FORM METHOD=POST ACTION="mailform.asp" ONSUBMIT="DoctorElements();">
<INPUT TYPE=HIDDEN NAME="urlSendTo" VALUE="/suggestions/thankyou.htm">
<INPUT TYPE=HIDDEN NAME="urlFromPath" VALUE="/suggestions/default.htm">
Name: <INPUT TYPE=TEXT NAME="txtUser.Name"><BR>
Email Address: <INPUT TYPE=TEXT NAME="txtUser.Name"><BR>
Type of Suggestion, complaints and compliments:
<SELECT NAME=selUser.Age SIZE=1>
<OPTION VALUE="None">None</OPTION>
<OPTION VALUE="Employee Compliment">Employee Compliment</OPTION>
<OPTION VALUE="Employee Recognition">Employee Recognition</OPTION>
<OPTION VALUE="Complaint">Complaint</OPTION>
<OPTION VALUE="Suggestion">Suggestion</OPTION>
<OPTION VALUE="Cultural Events">Cultural Events</OPTION>
<OPTION VALUE="Other">Other (Please fill this on the textarea)</OPTION>
</SELECT><BR>
Sex:
<BR>
<INPUT TYPE=RADIO NAME=radSex VALUE="Male" CHECKED>Male<BR>
<INPUT TYPE=RADIO NAME=radSex VALUE="Female">Female
<br><TEXTAREA ROWS="25" COLUMN="100" WRAP ></TEXTAREA>
<P><INPUT TYPE=SUBMIT value="Submit"> <INPUT TYPE=RESET VALUE="Reset" />
</FORM>
--------------------------------------------------------------------------------------
ASP File:
<%@ Language=VBScript %>
<% Option Explicit %>
<%
'The header/footer for the email.
Const strHeader = "Suggestions, comments, and concerns at Avanquest USA"
Const strFooter = "Avanquest Publishing USA publishes best selling and award-winning small business software, PC utilities and digital media products to create a powerful software line up of more than 50 products available in over 10,000 retail outlets across North America, including Wal-Mart, Staples, Office Depot, Office Max and Comp USA."
'Who does this go to? MAKE SURE TO CHANGE THIS TO YOUR EMAIL ADDRESS!
Const strTo = "jadem@avanquestusa.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 = "You will find suggestions, comments and concerns at Avanquest USA"
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
%>