Skip to main content
January 10, 2012
Answered

Passing a URL value to a CFC

  • January 10, 2012
  • 1 reply
  • 737 views

Hello.

I am not very familiar with coldfusion cfcs but I have been able to follow a few examples that allow me to do related selects using cfc code.

Recently I ran into an issue and can't figure out the answer using Google so I thought I'd ask here.

I have a form and the URL for that form contains a variable that I need to pass to the cfc but I'm not sure how.

Here is the URL.... myform.cfm?type=normal

Then on that myform.cfm page I have a call to a cfc like this <cfselect multiple="no" name="test" bind="cfc:test.test_func()" bindonload="true"/>

In the CFC I need to be able to change the query in the test_func based on the variable named "type" in the form page's URL string.

How can I pass that type=normal into the cfc with the bind in the cfselect???

Thanks

    This topic has been closed for replies.
    Correct answer

    Ok got it.  In the form I added a hidden field named field_val with value="#URL.type#" and then passed that form value like this bind="cfc:test.test_func({field_val})"

    Then in the cfc I set an argument to look for field_val and it works.

    Probably not the most elegant but its working for now.

    1 reply

    Correct answer
    January 10, 2012

    Ok got it.  In the form I added a hidden field named field_val with value="#URL.type#" and then passed that form value like this bind="cfc:test.test_func({field_val})"

    Then in the cfc I set an argument to look for field_val and it works.

    Probably not the most elegant but its working for now.