Skip to main content
Participant
June 26, 2013
Question

cfmail question

  • June 26, 2013
  • 1 reply
  • 402 views

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!!

This topic has been closed for replies.

1 reply

BKBK
Community Expert
Community Expert
July 6, 2013

rhsneed wrote:

...a check box that is check by default....

<cfif isDefined("form.mailList") AND Len(form.mailList)><cfif NOT Compare(#form.mailList#,"0")>yes<cfelse>no</cfif></cfif>

Nothing is submitted when the checkbox is unchecked. So, you could simplify you code thus:

<cfif isDefined("form.mailList")>

Yes

<cfelse>

No

</cfif>