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

Need Help with Processing Script

Explorer ,
Jul 02, 2008 Jul 02, 2008
Well I'm back again for the 2nd time today. I'd like to thank everyone who helped me out with my last issue. But now I have another issue that I'm trying to work out. Craig & Dan here helped me with sending out 2 separate email responders based off of questions asked in the cfform.

You can view the form at this link:
http://mswebsol.com/gaslockguarantee/creditapplication.cfm

The problem I'm having right now is that I'm not getting the results I'm looking for. Basically lets say you choose yes for 4 questions but on the 5th question you choose no. Well as it stands right now the script will send out the email response that says your accepted. But what I'm trying to do is if you choose no for any one of the questions you will automatically get an email response that says you're not accepted.

If I choose no for the first question I will get the correct email response which is "your not accepted" so it works for the first question. But if you choose yes for the first question and no for the 2nd or any other question you will get the wrong response that says "you are accepted."

So here's the code

<cfif StructKeyExists(form,"Q1")>
<cfif form.Q1 is "yes">
<cfmail>accepted....</cfmail>
<cfelse>
<cfmail>not accepted...</cfmail>
</cfif>

<cfelseif StructKeyExists(form,"Q2")>
<cfif form.Q2 eq "yes">
<cfmail>accepted....</cfmail>
<cfelse>
<cfmail>not accepted...</cfmail>
</cfif>

<cfelseif StructKeyExists(form,"Q3")>
<cfif form.Q3 eq "yes">
<cfmail>accepted....</cfmail>
<cfelse>
<cfmail>not accepted...</cfmail>
</cfif>

<cfelseif StructKeyExists(form,"Q4")>
<cfif form.Q4 eq "yes">
<cfmail>accepted....</cfmail>
<cfelse>
<cfmail>not accepted...</cfmail>
</cfif>

<cfelseif StructKeyExists(form,"Q5")>
<cfif form.Q5 eq "yes">
<cfmail>accepted....</cfmail>
<cfelse>
<cfmail>not accepted...</cfmail>
</cfif>
</cfif>

Any help would greatly be appreciated!

Thank you all

Derek Bess
Newbie @ Coldfusion
TOPICS
Getting started
293
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

correct answers 1 Correct answer

LEGEND , Jul 02, 2008 Jul 02, 2008
if i understand you correctly, all your if/else logic boils down to simple:
1) one of the answers is "No" - send "rejected" email
2) all answers are "Yes" - send "accepted" email

i suggest you cfparam all the answers with default="no" on your action
page, so that you do not have to keep checking for structkeyexists:

<cfparam name="form.q1" default="no">
...
<cfparam name="form.qN" default="no">

after that all you need is:

<cfif form.q1 is 'No' OR form.q2 is 'No' OR ... OR form.qN is 'No'>
.....
Translate
LEGEND ,
Jul 02, 2008 Jul 02, 2008
if i understand you correctly, all your if/else logic boils down to simple:
1) one of the answers is "No" - send "rejected" email
2) all answers are "Yes" - send "accepted" email

i suggest you cfparam all the answers with default="no" on your action
page, so that you do not have to keep checking for structkeyexists:

<cfparam name="form.q1" default="no">
...
<cfparam name="form.qN" default="no">

after that all you need is:

<cfif form.q1 is 'No' OR form.q2 is 'No' OR ... OR form.qN is 'No'>
...send 'rejected' email code here...
<cfelse>
...send 'accepted' email code here...
</cfif>

hth


Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
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
Explorer ,
Jul 03, 2008 Jul 03, 2008
LATEST
Azadi
Thanks for the help! That's exactly what I was looking for. My script now works 100%!

Thanks for the help. I really appreciate it.

Derek
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
LEGEND ,
Jul 02, 2008 Jul 02, 2008
You said,
"But what I'm trying to do is if you choose no for any one of the questions you will automatically get an email response that says you're not accepted."

If you ignore everything else do you see the potential for simplification?
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