Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

cfmail question

New Here ,
Jun 26, 2013 Jun 26, 2013

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

TOPICS
Advanced techniques
376
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 06, 2013 Jul 06, 2013
LATEST

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>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources