|
From: jqcf on 3 Apr 2008 12:20 Let's say you have a url like this: /page.cfm/var1.valueofvar1-var2.valueofvar2-var3.valueofvar3 And in some cases, the url is something like this: /page.cfm/var1.valueofvar1-var2.valueofvar2-var3.valueofvar3?gclid=239084327akdf gj And, all you really care about is getting the value of var3. How might you write some code to get the value of var3? Here's some code I came up with that actually seems to work: <cfset productID = ListFirst(ListLast(cgi.PATH_INFO,"."),"&")> But, I'm not sure this all is good practice really. So far, it seems to work without any problems that I can forsee. Anyone else find a problem with this?
From: Kronin555 on 3 Apr 2008 12:39 If you're guaranteed that var3 will always be the last var, then that should work. Seems very fragile to me, though. That whole method seems fragile. You can't have any periods or dashes in your variable values, or it breaks. What if you ever want a variable name with a dash in it?
From: Dan Bracuk on 3 Apr 2008 15:01 [q][i]Originally posted by: [b][b]Kronin555[/b][/b][/i] What if you ever want a variable name with a dash in it?[/q] Something like this: Invalid CFML construct found on line 16 at column 8.
From: Kronin555 on 3 Apr 2008 15:22 Dan, I wasn't talking about a CF variable. I was talking about a variable in the form that jqcf is using. /page.cfm/var1.valueofvar1-var2.valueofvar2-var3.valueofvar3 If var1's name wasn't var1, but was, for sake of argument, "my-var", then the URL becomes: /page.cfm/my-var.valueofmyvar-var2.valueofvar2-var3.valueofvar3 I know CF doesn't support variable names with dashes. Doesn't mean you can't use them elsewhere. Your form field names can include dashes, URL variables can include dashes, etc. If you do have a URL variable with a dash in it, you can access it as: URL['my-var'] I was simply saying that putting variables in the URL the way jqcf is asking about seems very fragile to me. The dash in a variable name was just an example. The method he's using, his variable values can't have any dashes or periods in them either.
From: Dinghus on 4 Apr 2008 19:55 Is there a legitimate reason for NOT just going with the standard format of mypage.cfm?var1=valofvar1&var2=valofvar2 And so on?
|
Pages: 1 Prev: 2 indentical processes at same time Next: Empty Space Generated by Coldfusion |