3 Replies Latest reply on Oct 17, 2008 4:41 PM by splitzer

    html form data to cfc

    ProjectedSurplus Level 1
      I've crawled inside and out of the documentation for how to pass html form data to a cfc and display the result (see http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=buildingComponents_15.ht ml) but -- possibly due to "If the CFC returns a result using the cfreturn tag, ColdFusion converts the text to HTML edit format, puts it in a WDDX packet, and includes the packet in the HTML that it returns to the client." -- I cannot find any way to display the results of passing info either by form or URL ( all that happens on form submit is this url http://70.XX.XX.XX:8500/olo/cfc/SearchOwners.cfc?method=getEmp in the address bar and a completely empty screen).

      My .CFM FIle:
      <h2>Find People</h2>
      <form action="../cfc/SearchOwners.cfc?method=getEmp" method="post">
      <p>Enter employee's last Name:</p>
      <input type="Text" name="lastName">
      <input type="Hidden" name="method" value="getEmp">
      <input type="Submit" title="Submit Query"><br>
      </form>


      My .CFC File
      <cfcomponent>
      <cffunction name="getEmp" access="remote">
      <cfargument name="lastName" required="true">
      <cfset var empQuery="">
      <cfquery name="empQuery" datasource="OLO">
      SELECT *
      FROM owners
      WHERE family_name = '#arguments.lastName#'
      </cfquery>
      <cfoutput>Results filtered by #arguments.lastName#:</cfoutput><br>
      <cfdump var=#empQuery#>
      </cffunction>
      </cfcomponent>

      Yet this invoke cfm works no problem returning results
      <body>
      <!--- Invoke Component. --->
      <cfinvoke component="olo.cfc.SearchOwners" method="getEmp" returnvariable="qResult">
      <cfinvokeargument name="lastName" value="name"/>
      </cfinvoke>
      </body>

      I SERIOUSLY will appreciate anyone who can help . . . . . .
        • 1. Re: html form data to cfc
          Dan Bracuk Level 5
          Don't submit to the cfc. Submit to a cfm page that calls the cfc.

          • 2. Re: html form data to cfc
            fober1 Level 1
            Hi,
            You should be able to call a cfc function directly from a web browser.

            Save the attached sample as "remote_library.cfc", and open it in the browser as "remote_library.cfc?method=form" to see how it works.

            Now find out what's different with your function (start with finding out if the datasource is there and working)

            cheers,
            fober
            =============================================

            <cfcomponent>
            <cffunction access="remote" name="say_hi" output="Yes">
            <cfargument name="fname" default="">
            <cfargument name="lname" default="">
            <cfargument name="phone" default="">
            Hi #fname#,<br>
            This is a test for #fname# #lname# with the phone number #phone#.<br>
            <br>
            <cfdump var="#url#">
            </cffunction>

            <cffunction access="remote" name="form" output="Yes">
            <h1>TEST</h1>
            <form action="remote_library.cfc?method=say_hi" method="post">
            <input type="Text" name="fname" value="Al">
            <input type="Text" name="lname" value="Gore">
            <input type="Text" name="phone" value="123 456-7890">
            <input type="Submit" name="btn" value="find">
            </form>
            </cffunction>

            </cfcomponent>
            • 3. Re: html form data to cfc
              splitzer Level 1
              You need to send the form to cfm template. The one you have invoke argument. Invoke argument sends the data to cfc, not the form.

              Syed