Skip navigation
Currently Being Moderated

CFIF / CFELSE Coding Question

Jun 7, 2011 3:00 PM

I'm not very proficient in ColdFusion but can usually get by. However, we added a third member category option and I can't seem to get the coding to work properly. Here's what we are trying to do:

 

There are 3 categories to choose from: Growing Company, Investor and Professional. Under Growing Company there are 3 different levels to choose from (there used to only be 2). For Investors and Professionals it is just one level.

 

Here is the current, broken code. We are finding that people who try to join at the $255 level or at the $695 team are seeing BOTH categories -- they are getting confused as to what they are signing up for.

 

<CFIF #memberCategory# IS "companyMember">
           <CFIF #memberType# IS "growingTeam">

 


               Membership Category: <b>Entrepreneur &amp; Management Team, Team Membership - $695</b>
</CFIF>

 

           <CFIF #memberType# IS "growingSingle">
                       Membership Category: <b>Entrepreneur &amp; Management Team, Single Membership - $495</b>
        <CFELSE>
               Membership Category: <b>Entrepreneur &amp; Management Team, 2011 Entrepreneur - $255</b>

 


           </CFIF>

 

       <CFELSEIF #memberCategory# IS "investorMember">
               Membership Category: <b>Investor - $495</b>

 

       <CFELSE>
               Membership Category: <b>Professional - $895</b>

 

       </CFIF>

 

Before adding this new $255 level, everything worked well. Anyone have a solution?

 

Your help is greatly appreciated. Thank you!

Tonya

 
Replies
  • Currently Being Moderated
    Jun 7, 2011 3:09 PM   in reply to tsmintc

    The way your logic is structured you are going to get ONE of Category A AND one of Category B.

     

    I.E. your member category logic and member type logic is NOT mutually exclusive.  OUTPUT from both is going to occur.

     

    This is an exercise in basic programming boolean logic and is not specific to CFML.  It is hard to say how to help you, since I am not really sure what you are tyring to do.  But it looks like you need some AND and|or OR clauses in your logic.

     

    The crudest example might just be something like.

     

    if membercategory IS 'companyMember" AND membertype is 'growingTeam'
         ... 695
    else if membercategory IS 'companyMember' AND membertype is 'growingSingle'
         ... 495
    
    .....
    

     

    But I would need to know a lot more about your business requirements then I can glean from this code example to provide a proper boolean logic tree.

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 7, 2011 3:15 PM   in reply to tsmintc

    You may have lucked out.  I got curious and played with this.

     

    Is this what you are trying to do?

     

    <CFIF memberCategory IS "companyMember">
        <CFIF memberType IS "growingTeam">
            Membership Category: <b>Entrepreneur &amp; Management Team, Team Membership - $695</b>
        <CFELSEIF memberType IS "growingSingle">    
            Membership Category: <b>Entrepreneur &amp; Management Team, Single Membership - $495</b>
        <CFELSE>
            Membership Category: <b>Entrepreneur &amp; Management Team, 2011 Entrepreneur - $255</b>
        </CFIF> 
    <CFELSEIF memberCategory IS "investorMember">
        Membership Category: <b>Investor - $495</b>
    <CFELSE>
        Membership Category: <b>Professional - $895</b>
    </CFIF>

     

    You may see how proper spacing can help sort out the logic.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points