Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jun 2011
    Posts
    148
    Thanks
    18
    Thanked 0 Times in 0 Posts

    URL encodedFormat

    Hi Peers,

    i'am trying to pass a URL "encodedFormat" string to another page.
    I'am having trouble to pass symbols like # otherwise everything else seem to work.

    source page


    Code:
    <cfset var1="abc$d"> 
    <cflocation url="URLDECODE.cfm?var11=#urlEncodedFormat(var1)#">


    destination page


    Code:
    <cfoutput> 
    The url variable passed is : #URL.var11# </cfoutput>

    if i put var1="abc12#", this will gimme an error ...

    problem happens with "#" symbol ...


    Thoughts

  • #2
    Senior Coder
    Join Date
    Aug 2010
    Location
    High Point, NC
    Posts
    3,333
    Thanks
    5
    Thanked 363 Times in 360 Posts
    Quote Originally Posted by korssane View Post
    Hi Peers,

    i'am trying to pass a URL "encodedFormat" string to another page.
    I'am having trouble to pass symbols like # otherwise everything else seem to work.

    source page


    Code:
    <cfset var1="abc$d"> 
    <cflocation url="URLDECODE.cfm?var11=#urlEncodedFormat(var1)#">


    destination page


    Code:
    <cfoutput> 
    The url variable passed is : #URL.var11# </cfoutput>

    if i put var1="abc12#", this will gimme an error ...

    problem happens with "#" symbol ...


    Thoughts
    Since the # symbol is a special character in coldfusion, you need to escape it in a string. Try "abc12##" instead.
    Teed

  • #3
    Regular Coder
    Join Date
    Jun 2011
    Posts
    148
    Thanks
    18
    Thanked 0 Times in 0 Posts
    hi teedoff,

    Thanks, but how if i'am passing a text field value and the user has entered a # sign in the text field ??..how can i double the # sign then..

    thanks.

  • #4
    Regular Coder
    Join Date
    Feb 2009
    Location
    NJ, USA
    Posts
    476
    Thanks
    2
    Thanked 70 Times in 69 Posts
    You shouldn't need to. This is only an issue when you are typing string literals with the '#' symbol into ColdFusion code. Putting in a <cfset something = "hi##"> will produce the literal string "hi#", which is then set to the variable something. In this case, the double hash symbol (##) in ColdFusion code escapes into a single hash symbol (#).

    However, whatever someone types into a textfield will not be parsed and processed by ColdFusion. They could type this into a textfield: "oogly #boogly#", and they will get the literal string "oogly #boogly#". However, if you put that in CF code as the value for say, a <cfset> (such as with <cfset something = "oogly #boogly#">), then you would get an error message: "variable 'boogly' is not defined".

    -Greg


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •