I want to get in ColdFusion 10 an URL parameter from CGI.QUERY_STRING by its name. How to do it without looping?
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 );
Related
I have created a POST request that is performed after some defined action.
Here I have its body:
<json type="object">
<variables type="object">
<customerId type="object">
<value ref="control-1">CUSTOMERID</value>
<type>String</type>
</customerId>
</variables>
</json>
What I'm trying to do is to get value from control-1 and replace the customerId->value value. It doesn't work. However, I noticed that setting name= instead of ref= makes the value empty.
The solution is to set service request value using XPath in action's editor:
/json/variables/customerId/value
Any idea about how can I send parameters in url query and get values of these parameters in next page
In first template I wrote this code
<a href ='r_rss/openOneNews?url={rss_link}'>{rss_title}</a>
Q:How can I get url parameter value in ExpressionEngine and use something like this in following page:
<iframe src = 'url' />
Thanks
See this answer - you want to use Mo' Variables to get the query string, which will then convert to a variable tag:
<iframe src = '{get:url}' />
Ahmed - please don't cross-post your question:
https://expressionengine.stackexchange.com/questions/14546/form-post-values
https://expressionengine.stackexchange.com/questions/14548/sending-paramters-in-url
Below I have this code:
string _strTemplate = _strDownloadTemplate + IDReq + "/" + _strFileName;
Uri url = new Uri(_strTemplate);
As you can see, I'm converting the strTemplate (which carries the link of a page that I need to sent by email for the user) to a URL Format. My email body has several fields that I'm replacing with the correct value:
strMailMessage = strMailMessage.Replace("_LinkTemplate", url);
I'm getting an error because the method string.Replace takes strings as parameters only.
Is there a way to get around this?
I was thinking about pass the URL value through my page (page.aspx) but if there's a way to do so through this method, it would be better for me.
Thanks!
Assuming this is C# and .NET, yes, String.Replace() works with strings.
Did you try:
strMailMessage = strMailMessage.Replace("_LinkTemplate", url.ToString());
I'm sure this is quite simple but I can't seem to get it right
In ColdFusionI've encrypted a querystring and then decrypted the CGI.Query_String value easily enough. I then have a single string which looks like a querystring. But I need to reference the querystring values as I would normally using URL. notation (for example).
How do I do this?
I've tried the code below but can't seem to parse the values out of the structure:
<cfscript>
myStruct = structNew();
for(i=1; i LTE listLen(decrypted,'&');i=i+1) {
structInsert(myStruct, i, listGetAt(decrypted,i,'&'));
}
</cfscript>
Any help appreciated.
UPDATE: (More info if I wasn't clear)
I'm sending data via CFLOCATION with an encrypted querystring. Just to hide some irrelevant info from the user. What I want to do is use the querystring information after it has been decrypted. But I can no longer use the ColdFusion URL structure. So I'm asking how do I parse the information from the decrypted string so I can use it (e.g. within a where clause of a SQL query or simply just display on the page).
Say my decrypted string is update=0&balance=1145.00
How do I go about using something like <cfoutput>#update#</cfoutput>?
If str is your querystring:
<CFSET str = "asdf=1&asd&as=3" />
<CFSET mystruct = structnew() />
<CFLOOP list="#str#" delimiters="&" index="i">
<CFSET key = listfirst(i,"=") />
<CFIF listlen(i,"=") GT 1>
<CFSET value = listlast(i,"=") />
<CFELSE>
<CFSET value = "" />
</CFIF>
<CFSET mystruct[key] = value />
</CFLOOP>
This seems trivial
<cfset username = urldecode(url.username, "utf-8")>
Where username in the URL = %F8yvind
Decoded username = �yvind
How do I get the corresponding html entity: ø?
I need to use the username as a lookup value in the db.
Thanks!
<cfset username = htmlEditFormat(urlDecode(URL.username, "utf-8"))>
Does this work?