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">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<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
%>

I need some help how to put email addresses in a textfield, then this is directed on the To: of the inbox.

I think that would be an easy method to do this, but I'm new to ASP. I need some help.

still not sure what you are asking.. but here's what i think?

you are asking how to add a textfield where people can put their email address in? if so, easy:
<input type="text" id="email" name="email" />

in your coding:
Dim strTo = Request.Form("email")
'remove your other strTo statement.

I think did some modification from the code you gave me. Thanks.

Now I added a textarea on my form, and how would I include the ASP code. After the user types in the message it will also generate the result via email.

same way.

Dim strText = Request.Form("textareaname")
Dim strBody = strHeader & vbCrLf _
& "FORM: " & strFromPath & vbCrLf _
& "FORM submitted at " & Now() & vbCrLf _
& strText

Dim is for declaring variables, like strText or strBody.
str is to indicate it is a string, like int is for integer.
strName is the variable that you declare.
strName = value sets the variable with a value and can be later called with just the variable name, strName.
When working with forms, you use Request.Form("formelementnameandid") to receive the value of that form element, like a textbox or text area.

vbCrLf is visual basic language for a new line. the " _" symbol just means that there is a continuation to the variable on the next line of the code. the above example is that same as "Dim strBody = strHeader & vbCrLf & "FORM: " & strFromPath & vbCrLf & "FORM submitted at " & Now() & vbCrLf & strText" ASP reads the lines faster when you break them up into smaller parts and just make it read the very next line. So it is faster coding to do it the above way that you already used.

This article has been dead for over six months. Start a new discussion instead.