1

When a Coldfusion form calls a cfc as the action, is it possible for the browser to stay on the form page or does the component function have to reroute it back to the form page?

<cfform name="crops" action="cfc/stages.cfc?method=update" method="post">

Once the form above is posted, it stays on the component page rather than rerouting back to the form page.

Robin
  • 91
  • 12
  • 4
    You need to look into using AJAX to submit the form. You really can't submit a form the way you mentioned directly to a CFC. Oh, and stop using `cfform` it will be more trouble than it is worth. Use a plain old HTML form. – Scott Stroz May 18 '15 at 18:58
  • Take a look at the answer I posted for a similar question. It should get you started with the form HTML, JavaScript to post the data via Ajax and a simple CFC function to verify that it received the data correctly. http://stackoverflow.com/questions/11461078/post-parameters-from-ajax-request-undefined-in-form-scope-in-coldfusion/11472873#11472873 – Adrian J. Moreno May 18 '15 at 19:17
  • Adrian, I want to thank you. I revisited your post today. Your sample code in the link you provided was helpful. I'm still absorbing jquery and js. – Robin Nov 09 '15 at 17:05

1 Answers1

1

A simple way to accomplish what you appear to want is to submit the form to the page containing it. No ajax required.

<cfif StructKeyExists(form, "aKnownFormField")>
code to process form
can use create object to access cfc code if you want
</cfif>
<form action="thePageIAmOn.cfm" method="post">
<input name="aKnownFormField" type = "text">
more form fields
</form>
Dan Bracuk
  • 20,699
  • 4
  • 26
  • 43