Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Check for URL Parameter

Status
Not open for further replies.

AlanDI1

Programmer
Apr 20, 2003
56
I have CF module that may or may not be passed a parameter in the URL. I want to check and see it the parameter is there otherwise use a default.

<cfif isDefined("URL.SelectDate") >
<cfset lnSelectCYCYMM = #URL.SelectDate#>
</cfif>

This code produces "This page cannot be displayed" message.

Can anyone tell me how to fix it or another way to check for the existance of the parameter.

Thanks
 
If you still want to use CFIF's you can do:

Code:
<cfif isDefined("URL.SelectDate")>
    <cfset lnSelectCYCYMM = #URL.SelectDate#>
<cfelse>
    <cfset lnSelectCYCYMM = "12/10/2005">
</cfif>


____________________________________
Just Imagine.
 
i prefer CFPARAMs because you canmake them "cascade"

let's say that you want to pick up a parameter value form either the user's cookie or the url, but if the url parameter is specified, it has priority

<CFPARAM NAME="cookie.SelectDate" DEFAULT="2005-12-11">
<CFPARAM NAME="url.SelectDate" DEFAULT="#cookie.SelectDate#">
<CFSET lnSelectCYCYMM = url.SelectDate>

to do the same with CFIFs is substantially messier :)


r937.com | rudy.ca
 
r937, I agree CFPARAM NAME is the better way of doing things. But my solution was just in case AlanDI1 wanted to use <cfif></cfif>


____________________________________
Just Imagine.
 
Thanks to all. That gives me plenty to work with. I appreciate all your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top