Robert,

Since the box is either "checked" or "Unchecked" that's all you need. You
don't really need to worry about the value at all. If the form field shows
up then the user checked the box. That's how checkboxes work.

Subscribe To Newsletter? <cfif
structKetyExists(form,'maillist')>Yes<cfelse>No</cfif>

Notice I use structkey exists. Also you do not need pound signs around
#form.mailist# unless you intend for it to be displayed :)

Here's another approach for you.

In the checkbox attributes set value="1" (instead of zero). Then wherever
you set up default values add this cfparam.


<cfparam name="form.maillist" default="0"/>


Then you can leverage the YesNoFormat(  ) function of CF... 

Subscribe To e-Newsletter?  #yesNoFormat(form.maillist)#


Good luck!



Mark Kruger - CFG
CF Webtools
www.cfwebtools.com
www.coldfusionmuse.com
O: 402.932.3318
E: mkru...@cfwebtools.com
Skype: markakruger




-----Original Message-----
From: Robert Sneed [mailto:robertsn...@rhsneed.com] 
Sent: Friday, June 28, 2013 8:17 AM
To: cf-talk
Subject: CFMail Question


I hope someone can help me with this. I'm kind of stuck on the conditional.

I have a newsletter signup form that includes a check box that is check by
default.

<label for="mailList"><input checked="checked" id="mailList" name="mailList"
tabindex="14" type="checkbox" value="0" width="5px" /><span
class="checkbox">I would like to receive your e-newsletter.</span></label>

I'm trying to email the answer, yes or no, based on whether or not the box
is checked. Here is the conditional code between my <cfmail></cfmail> tags.

Subscribe to e-newsletter? <cfif isDefined("form.mailList") AND
Len(form.mailList)><cfif NOT
Compare(#form.mailList#,"0")>yes<cfelse>no</cfif></cfif>

If someone checks the box I get the sentence "Subscribe to e-newsletter?
Yes" in an email. If someone does not check the box I get "Subscribe to
e-newsletter?" I can't figure out how to get the "No" to show up in the
email when the box is not checked.

I feal like I'm close here but just can't seem to get the "No" answer
emailed when the box is not checked.

Thanks a lot for your help!! 



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:356092
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to