Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ColdFusion: get url parameter by name

I want to get in ColdFusion 10 an URL parameter from CGI.QUERY_STRING by its name. How to do it without looping?

like image 481
Paul Avatar asked Aug 02 '13 16:08

Paul


1 Answers

Any values passed in to a page via the query string are available in the URL scope.

Assume you have a query string that looks like http://mydomain.com?val1=42&val2=moo you would access the variables by referencing them as such

<cfset myVal1 = url.val1 />
<cfset myVal2 = url.val2 />

Or, in cfscript

myVal1 = url.val1;
myVal2 = url.val2;

To see all the values passed in via query string, you can also dump out the URL scope.

<cfdump var="#url#" />

or, in cfscript

writeDump( url );
like image 184
Scott Stroz Avatar answered Sep 28 '22 00:09

Scott Stroz