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

    Join Date
    Mar 2011
    Posts
    6
    Rep Power
    0

    Trouble passing CF variable with URL


    I am very new to ColdFusion and have a simple problem which I have spent too much time trying to figure out. When I put an actual value in place of #deptsel# in file1 it displays fine, but not with a CF variable.

    I have code such as the following in file1.cfm.

    <cfset deptsel=5>
    <a href="request_caller.cfm?dept=#deptsel#">send to next form</a>

    In file2.cfm I have something like:

    <cfoutput> dept=#url.deptsel# <br /> </cfoutput>

    I don't get an error, but I simply get back:

    deptsel=

    I appreciate any help and sorry it is such a simple thing
  2. #2
  3. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,264
    Rep Power
    968
    You're referencing #url.deptsel#, but the url parameter you're passing is named "dept". Change your file2.cfm to:

    <cfoutput> dept=#url.dept#<br /></cfoutput>
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2011
    Posts
    6
    Rep Power
    0
    This is embarrassing... Thanks for the correction. Actually, I had it correct in my code but had it wrong on my post. It just doesn't want to work. To display the value, do I need to do something different? Here's my actual code, all of it!:

    <cfset deptsel=7>
    <CFOUTPUT> In gen_req -- deptsel= #deptsel# <br /> <br /></CFOUTPUT>
    <a href="../common/request_caller.cfm?dept=#deptsel#">send to next form</a>

    and the other .cfm file:

    <cfoutput> in request_caller - dept=#url.dept#<br /></cfoutput>
  6. #4
  7. No Profile Picture
    Moderator

    Join Date
    Jun 2002
    Location
    Raleigh, NC
    Posts
    5,264
    Rep Power
    968
    You need to move the closing </cfoutput> so that your link is inside it.

    Code:
    <cfset deptsel=7>
    <CFOUTPUT> 
    In gen_req -- deptsel= #deptsel# <br /> <br />
    <a href="../common/request_caller.cfm?dept=#deptsel#">send to next form</a>
    </CFOUTPUT>
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2011
    Posts
    6
    Rep Power
    0
    Thanks, Runs much better that way ...

    Larry
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2011
    Posts
    1
    Rep Power
    0

    CF newbie


    I am also a newbie in using CF and I will really appreciate some tips and advices to maximize its use.

IMN logo majestic logo threadwatch logo seochat tools logo