| | |
need help building radio buttons in a dynamic asp form
Please support our ASP.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2006
Posts: 19
Reputation:
Solved Threads: 0
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
%>
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
%>
•
•
Join Date: Sep 2007
Posts: 1,080
Reputation:
Solved Threads: 68
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.
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.
Last edited by SheSaidImaPregy; Oct 29th, 2007 at 7:07 pm.
![]() |
Similar Threads
- Arrrgggghhhh... Radio Buttons are the bain of my life! Can someone please help. (ASP)
- Radio button help!! (ASP)
- Jmail with radio buttons and menus (Site Layout and Usability)
- asp form action script (Site Layout and Usability)
- dynamically generated textboxes & radio buttons php, insert into db (PHP)
- javascript: radio buttons (JavaScript / DHTML / AJAX)
- IE6 - dialogue boxes , check boxes and radio buttons work very slowly after hijacking (Viruses, Spyware and other Nasties)
Other Threads in the ASP.NET Forum
- Previous Thread: for help
- Next Thread: Could not create 'CDO.Message' object
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax appliances asp asp.net beginner bottomasp.net box browser businesslogiclayer button c# c#gridviewcolumn cac checkbox class click compatible confirmationcodegeneration content contenttype control countryselector courier css database datagrid datagridview datalist deadlock deployment development dgv dialog dropdownmenu dynamic dynamically edit embeddingactivexcontrol fileuploader fill findcontrol flash flv forms gridview gudi homeedition iframe iis javascript jquery list menu mono mssql multistepregistration nameisnotdeclared novell objects opera order problem ratings redirect registration relationaldatabases reportemail rotatepage search security serializesmo.table sessionvariables silverlight smartcard smoobjects software sql ssl tracking treeview validatedate validation vb.net virtualdirectory vista visual-studio visualstudio vs2008 web webapplications webarchitecture webdevelopment wizard xml xsl






