#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2007
    Posts
    4
    Rep Power
    0

    Passing variable into url


    Am sure am missing something but why doesnt this work???
    If I hardcode the string value it works fine...

    <cfset Str_Order =#rsorder.order_id#>
    <cfoutput> #Str_Order# </cfoutput>
    <p><a href="MyAccount.cfm?view=customsinvoice&amp;OrderID=' #Str_Order# ' "> test</a></p>
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2008
    Posts
    131
    Rep Power
    10
    You need to clarify "doesn't work". What is the value you are testing and what happens when you run the code, an error ... ?
  4. #3
  5. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,307
    Rep Power
    971
    The value in the URL is probably wrong? Try:

    a href="MyAccount.cfm?view=customsinvoice&OrderID=#Str_Order#">test</a></p>
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2009
    Posts
    138
    Rep Power
    19
    Originally Posted by chuck1rar
    Am sure am missing something but why doesnt this work???
    If I hardcode the string value it works fine...

    <cfset Str_Order =#rsorder.order_id#>
    <cfoutput> #Str_Order# </cfoutput>
    <p><a href="MyAccount.cfm?view=customsinvoice&amp;OrderID=' #Str_Order# ' "> test</a></p>
    Your A tag needs to be inside the CFOUTPUT otherwise the #Str_Order# will be read as a string instead of a variable.

    Code:
    <cfset Str_Order =#rsorder.order_id#>
    <cfoutput> #Str_Order# <p><a href="MyAccount.cfm?view=customsinvoice&amp;OrderID=' #Str_Order# ' "> test</a></p></cfoutput>
    That will give you the output you want.

IMN logo majestic logo threadwatch logo seochat tools logo