Skip to main content
Inspiring
March 16, 2012
Question

Need help with cfif, cfelseif

  • March 16, 2012
  • 4 replies
  • 1392 views

I am trying to display a slideshow within an include file depending upon what category selection someone makes within a CF page.

I have tried the following using both URL= and template= with no luck. Any help would be appreciated.

<cfif TxtProductMenuSelected eq "NewProducts">
                <cfinclude URL="IncludeFiles/ContractHome-include.cfm">
            <cfelseif TxtProductMenuSelected eq "Chandeliers">
                <cfinclude URL="IncludeFiles/ProdHome-include.cfm">
            <cfelseif TxtProductMenuSelected eq "LargeFixtures">
                <cfinclude URL="IncludeFiles/test-include.cfm">
            <cfelse>
                I don't have a clue! Seriously.
            </cfif>

    This topic has been closed for replies.

    4 replies

    Inspiring
    March 16, 2012

    I debug conditional logic problems like this:

    if (something)

    output yes

    else

    output what I expected and what I actually got

    In your case, once you know the if/else part is working, you can see what's going on with your included files.           

    btvbillbAuthor
    Inspiring
    March 16, 2012

    I removed all the if/else parts and the include file works fine by itself. I suspect the issue may be the <cfif TxtProductMenuSelected eq "NewProducts"> part which does not seem to be providing a value for TxtProductMenuSelected.

    btvbillbAuthor
    Inspiring
    March 16, 2012

    I have posted all the code below. Basically, it's a page that displays thumbnail images and a Flash slideshow depending upon which category is selected. I have commented out the Flash sildeshow and created include files for the code to a javascript slideshow instead. I was using TxtProductMenuSelected as the criteria for displaying the appropriate include file. Hope this all makes sense.

    http://www.cylonweb.com/test/test.cfm

    BKBK
    Community Expert
    Community Expert
    March 17, 2012

    btvbillb wrote:

    I have posted all the code below. Basically, it's a page that displays thumbnail images and a Flash slideshow depending upon which category is selected. I have commented out the Flash sildeshow and created include files for the code to a javascript slideshow instead. I was using TxtProductMenuSelected as the criteria for displaying the appropriate include file. Hope this all makes sense.

    http://www.cylonweb.com/test/test.cfm

    Your code is behaving as expected. The last line to update the value of the variable TxtProductMenuSelected before the if-else block is:

    <cfset TxtProductMenuSelected = "">

    That is why the comparisons with "NewProducts", etc. return false.

    btvbillbAuthor
    Inspiring
    March 19, 2012

    Thanks!

    Legend
    March 16, 2012

    In my cursory look at your code, it appears correct - syntax wise. My guess is that you may be confusing client side code with server side code. The code you are showing above is server side. Maybe describe your problem a little more.

    Inspiring
    March 16, 2012

    You don't actually say what the problem is that you're having.  You just say you're trying to do something.  I presume it's not working, but you don't tell us in what way it's not working.

    NB: docs for <cfinclude>: http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7ea7.html.  URL is not a valid attribute; template is the one you want.

    --
    Adam