Skip to main content
May 10, 2011
Question

ColdFusion 8 AJAX from Ben Forta

  • May 10, 2011
  • 1 reply
  • 455 views

I found sample codes written by Ben Forta and I want to used it for my application but since it is a bit different, I need to tweak it. Unfortunately it did not work (work partially).

I'm not sure how to call the component when user type in the AmountSent on the input text field so user can automatically get the list of fee in a drop down that is in the range of the amount typed in on thetext field (see below)

Thank you for helping.

On MyForm.cfm:

<!--- This part is working : User typing any amount of money and a list of autosuggest pop up --->

<cfquery name="datafee" datasource="#MyDSN#">

SELECT AmountSent

FROM tblFeeLookUp

ORDER BY FeeID

</cfquery>

Amount To Be SEND:

<cfinput

type="text" name="AmountSent" autosuggest="#ValueList(datafee.AmountSent)#" bindonload="true" class="inputText">

<!---  a drop down fee values associated with the amount typed in the above textbox: This one does not work --->

<!--- This section is calling cfcomponent (see below) --->

Your fee is:

<cfselect

name="MyFee" bind="cfc:FeeTemp.GetThisFees({cfautosuggestvalue})" class="inputText" /> ----> ????

On my component:

<cffunction name="GetThisFees" access="remote" returntype="array">

   <!--- Define variables --->

   <cfset var datafee="">

   <cfset var feeresult=ArrayNew(1)>

   <!--- Get transfer fee --->

   <cfquery name="datafee" datasource="#THIS.dsn#">

    SELECT FeeID,OurFee

    FROM TblFeeLookUp

    WHERE AmountSent = #ARGUMENTS.AmountSent#

    AND ProgramType = 'EKONOMI'

    AND AccountType = 'Rp'

    ORDER BY FeeID

   </cfquery>

    <!--- Build result array --->

   <cfloop query="datafee">

    <cfset ArrayAppend(feeresult, OurFee)>

  </cfloop>

  <cfreturn feesresult>

</cffunction>

This topic has been closed for replies.

1 reply

talofer99
Inspiring
May 13, 2011

looking at your code (you didn't explain what is not working for you ... do you get an error ?).. you forgot this :

<cfargument name="AmountSent" type="any" required="false" default="">

inside your CFC ... so if you are not getting any reponse it might be due to a CFC error ....

try to add this to the cfc function.

if this is not the problem, please add some more info on the What is not working...

Hope ti helps