Skip to main content
Inspiring
October 22, 2008
Answered

CFIF statement problems

  • October 22, 2008
  • 3 replies
  • 761 views
I'm trying to set a default variable for a website I'm creating and this code isn't working.

Any help would greatly be appreciated.

    This topic has been closed for replies.
    Correct answer xstortionist
    Thanks Mikey.

    This was the answer we were looking for.

    We tried to do the cfparam but we did it backwords.

    Can someone explain how this code functions?

    Thanks

    Derek

    3 replies

    October 22, 2008
    Basically, if url.dealer doesn't have a value, the CFPARAM kicks in and populates url.dealer with the default value you specify. It's a really nice and clean way of supplying a default value instead of doing loads of CFIF etc. However, it is kind of limited in some ways.

    Cheers!
    Mikey.
    Inspiring
    October 22, 2008
    I appreciate the breakdown Mikey. I'm saving this one in my memory banks.

    You wouldn't believe how long we worked on trying to get this to work.
    Known Participant
    October 22, 2008
    What error are you getting?
    It looks fine to me - although I tend to use single quotes isDefined ('URL.dealer')

    Michael
    October 22, 2008
    Not sure why it wouldn't work, seems fine to me. You could try the CFPARAM approach. E.g.

    <cfparam name="url.dealer" type="string" default="acura" />
    <cfset variables.dealername = url.dealer />
    <cfoutput>#url.dealer#</cfoutput>

    That should work - but check it!

    Thanks,
    Mikey.
    xstortionistAuthorCorrect answer
    Inspiring
    October 22, 2008
    Thanks Mikey.

    This was the answer we were looking for.

    We tried to do the cfparam but we did it backwords.

    Can someone explain how this code functions?

    Thanks

    Derek