Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFAjax Usage at a Dynamic Level

Status
Not open for further replies.

MinalMoe

IS-IT--Management
Mar 25, 2004
62
GB
I am using CFAjax for ColdFusion List Building.

The following code works very well.

<cffunction name="ResortLookup">
<cfargument name="Dest" required="yes" type="string">
<cfargument name="returnType" required="no">
<cfparam name="returnType" default="array">

<cfset Resort = ArrayNew(1)>
<cfif arguments.Dest eq "ADB">
<cfset ArrayAppend(Resort, "Altinkum")>
<cfset ArrayAppend(Resort, "Kusadai")>
</cfif>
<cfif arguments.Dest eq "AYT">
<cfset ArrayAppend(Resort, "Alanya")>
<cfset ArrayAppend(Resort, "Antalya")>
</cfif>
<cfif arguments.Dest eq "DLM">
<cfset ArrayAppend(Resort, "Calis Beach")>
<cfset ArrayAppend(Resort, "Hisaronu")>
</cfif>
<cfif arguments.Dest eq "999">
<cfset ArrayAppend(Resort, "Select your Resort")>
</cfif>

<cfif returnType EQ "struct">
<cfset retStruct = StructNew()>
<cfloop index="ctr" from="1" to="#ArrayLen(Resort)#">
<cfset StructInsert(retStruct, ctr, Resort[ctr])>
</cfloop>
<cfset Resort = retStruct>
</cfif>

<cfreturn Resort>
</cffunction>

But the code has to be entered at design time. I wanted to alter it to

<cffunction name="ResortLookup" hint="type='keyvalue' jsreturn='array'">
<cfargument name="Destination" required="yes" type="string">
<cfargument name="returnType" required="no">
<cfparam name="returnType" default="array">

<cfset Resort = ArrayNew(1)>
<cfloop query="Level_01">
<cfif arguments.Destination eq Trim(Link_Airport)>
<cfset ArrayAppend(Resort, "#Trim(Resort)#")>
</cfif>
</cfloop>
<cfif arguments.Destination eq "999">
<cfset ArrayAppend(Resort, "Select your Resort")>
</cfif>

<cfif returnType EQ "struct">
<cfset retStruct = StructNew()>
<cfloop index="ctr" from="1" to="#ArrayLen(Resort)#">
<cfset StructInsert(retStruct, ctr, Resort[ctr])>
</cfloop>
<cfset Resort = retStruct>
</cfif>

<cfreturn Resort>
</cffunction>

Where the query Level_01 looks at every destination and only selects those that match an Airport like ADB or AYT etc.

Although the appropriate code seems to be generated, it doesn't dynamically fill the List / Menu box.

Any ideas please.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top