Actually all you do is have a hidden from field named method that is the method
that you want to use. Also the method must have an access of "remote".
<form action="aCFC.cfc" ...>
...
<input type="hidden" name="method" value="formMethod">
</form>
Now, the caveat to this is that you are going to be setting on the cfc file
when this is all done. So you will likely be looking at a blank page in the
browser, with the url showing something like http://mysite/cfcs/aCFC.cfc.
What needs to happen is that the method called by the form needs to end in a
cflocation that redirects to whereever you want to be, when the form processing
is done.
An example from one of my projects
FORM TEMPLATE
<form action="CFC/ComplaintAction.cfc" method="post" name="ApprovalListForm"
class="complaintForm" id="ApprovalListForm">
....
<input name="method" type="submit" class="submit"
value="UpdateApprovalRequests">
</form>
COMPLAINTACTION.CFC
<cffunction access="remote" name="UpdateApprovalRequests" output="false">
.....
<cflocation addtoken="no" url="/ComplaintEdit.cfm">
</cffunction>
--------------
Ian Skinner
Web Programmer
BloodSource
www.BloodSource.org
Sacramento, CA
"C code. C code run. Run code run. Please!"
- Cynthia Dunning
....-----Original Message-----
....From: Barney Boisvert [mailto:[EMAIL PROTECTED]
....Sent: Monday, February 28, 2005 1:42 PM
....To: CF-Talk
....Subject: Re: Run CFC method on form submit
....
....Did you try this:
....
....<form action="/path/to/mycfc.cfc?method=myMethodName" action="post">
....
....That should do exactly what you want, if I understand you correctly.
....Just make sure your method has access="remote" so that it can be
....called remotely.
....
....cheers,
....barneyb
....
....On Mon, 28 Feb 2005 16:33:12 -0500, Yexley Robert D Contr AFRL/PROE
....<[EMAIL PROTECTED]> wrote:
....> I'm looking for some good documentation or a code sample for how I
....would execute a method in a CFC on form submit. So far I haven't been
....able to find what I'm looking for. What I'm trying to do seems like it
....ought to be fairly straight forward. I've got a method in a CFC that
....inserts a record into a database, it has 11 parameters. I've got an HTML
....form (not a <cfform>) in a ColdFusion template, and I'd like to set the
....method of this CFC to be the "method" for the form. When the form is
....submitted, I want the values of the fields on the form (there are 11 of
....them, corresponding to each of the parameters of the CFC method) to get
....passed into the CFC method as parameters, and then run the method. Can
....somebody point me to some documentation, or give me a good code sample?
....I've looked in the CFML Reference, and also "Developing ColdFusion MX
....Application with CFML" as well, and haven't been able to find anything
....that covers this sort of scenario.
....>
....> ================
....> // YEX //
....
....
....--
....Barney Boisvert
[EMAIL PROTECTED]
....360.319.6145
....http://www.barneyb.com/
....
....Got Gmail? I have 50 invites.
....
....
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking
application. Start tracking and documenting hours spent on a project or with a
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:196879
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54