Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CDONTS, check boxes and radio buttons

Status
Not open for further replies.

Boysie

Technical User
Nov 3, 2001
4
GB
I am using this which is fine so far -

<%
email = request.form(&quot;Email&quot;)

Dim objMail
Set objMail = Server.CreateObject(&quot;CDONTS.NewMail&quot;)
objMail.From = email
objMail.Subject = &quot;Enquiry From Web Site&quot;
objMail.To = &quot;myname@myURL.co.uk&quot;
ObjMail.BodyFormat = 1

body = &quot;Name&quot; & vbcrlf & request.form(&quot;name&quot;) & vbcrlf & vbcrlf
body = body & &quot;Address&quot; & vbcrlf & request.form(&quot;address&quot;) & vbcrlf & vbcrlf
body = body & &quot;Email address&quot; & vbcrlf & request.form(&quot;email&quot;) & vbcrlf &
vbcrlf

objMail.Body = body
objMail.Send

Set objMail = nothing
%>

However -

1) How do I deal with check boxes, and
2) How do I deal with radio buttons.

Thank you in advance

Pete Boys
 
I have some radio buttons on a form that have to be submitted using CDONTS, here's a snippet of code so you can see how i did it. there is probably a much easier way but this works :)


<%
If Request.Form(&quot;Submit&quot;) <> &quot;&quot; then
Dim objmail, mailbody
set objmail = CreateObject(&quot;CDONTS.NewMail&quot;)
objmail.From = Request.Form(&quot;PersonalInfoEmailAddress&quot;)
objmail.To = &quot;someone@somewhere.com&quot;
objmail.Subject = &quot;Online Job Application&quot;

'-------------------------Radio Buttons-------------------------
'This is the logic to select if a radio button on the form is checked Yes or No. Then in the E-Mail it will display a Yes or No as an answer to the question asked.

Answer18 = Request.Form(&quot;18OrOlder&quot;)
If Answer18 = &quot;Yes&quot; Then
Response.Write &quot;Yes&quot;
Else
Response.Write &quot;No&quot;
End If

AnswerTravel = Request.Form(&quot;TravelOvernight&quot;)
If AnswerTravel = &quot;Yes&quot; Then
Response.Write &quot;Yes&quot;
Else
Response.Write &quot;No&quot;
End If

AnswerLicense = Request.Form(&quot;ValidDriversLicense&quot;)
If AnswerLicense = &quot;Yes&quot; Then
Response.Write &quot;Yes&quot;
Else
Response.Write &quot;No&quot;
End If
 
Pete,

Do you want to display radio buttons and checkboxes in your email or do you want to be able to read the values of radio buttons and checkboxes from the posted form collection ??

ToddWW
 
I want to show the values in an email e.g. if a user checks the check boxes for information on -

wills
fafily law

but does not check

criminal
other

then the email will have in the body

Send me information on -
wills
family law

Same sort of thing with radio buttons for a simple two option situation e.g.

then the email will have in the body

My property is
Freehold
 
Well, when dealing with checkboxes, the easiest way is to just supply a name for the checkbox. Like this.
Code:
<input type=&quot;checkbox&quot; name=&quot;wills&quot;>Wills</input>
Now, on the ASP code that is processing the form collection, Request.Form(&quot;wills&quot;) will return a value of on or off depending if the checkbox is checked or not.

For radio buttons, they are a little different because each radio button has the same name. So you want to provide a value in those like this.
Code:
<input type=&quot;radio&quot; name=&quot;property&quot; value=&quot;freehold&quot;>Freehold</input>
<input type=&quot;radio&quot; name=&quot;property&quot; value=&quot;freemoney&quot;>Free Money</input>
When you examine the radio button with Request.Form(&quot;property&quot;) you'll get freehold if that button was checked or freemoney if that button was checked or no value at all if nothing was checked.

ToddWW
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top