I'm going to start off by saying that I am a brand new user of
cfajax. I'm working on an application that already has cfajax to
populate a single drop down list and i'm using this code. I am trying
to create a form with 3 recursive calls to the database which
populates the drop down lists.
The attached code is just my starting point. I'm trying to get the
first drop down list activate the code to populate the second drop
down list but i'm having no luck. And since i'm not receiving an
error message it's difficult to figure out why nothing is happening.
Anybody have a thought as to what i'm missing? Or know a website that
can assist me in this?
Any help is greatly appreciated. Thanks in advanced!
Jennifer
Attached Code:
____________________________________________________________
<script language="JavaScript" type="text/javascript">
function getBuyNames() {
var PlanFilter = DWRUtil.getValue("planName");
var username =
<cfoutput>'#session.username#'</cfoutput>;
var accesslevel =
<cfoutput>#session.accesslevel#</cfoutput>;
var fuseaction =
<cfoutput>'#URL.fuseaction#'</cfoutput>;
var arglist = PlanFilter + "," + username + "," +
accesslevel + "," + fuseaction;
DWREngine._execute(_cfscriptLocation,
null, 'buyNamelookup', arglist, getBuyNameResult);
}
function getBuyNameResult(buyArray){
DWRUtil.removeAllOptions("buyName");
DWRUtil.addOptions("buyName",
buyArray, "KEY", "VALUE");
}
</script>
____________________________________________________________________
<cffunction name="buyNamelookup">
<cfargument name="arglist" required="yes" type="string">
<cfargument name="returnType" required="no">
<cfparam name="returnType" default="array">
<cfset PlanFilter=ListGetAt(arglist,1)>
<cfset username=ListGetAt(arglist,2)>
<cfset accesslevel=ListGetAt(arglist,3)>
<cfset fuseaction=ListGetAt(arglist,4)>
<cfquery name="selectBuyNames" datasource="#DSN#">
SELECT DISTINCT buyName
FROM tblAtlasStruct
WHERE 0=0
AND planName = '#PlanFilter#'
ORDER BY buyName
</cfquery>
<!--- Creates List of buyNamess --->
<cfset List_selectbuyName = ValueList
(selectBuyNames.buyName,"¬")>
<!--- Create Key/Value Pair List --->
<cfset valueTextList="">
<cfset i=1>
<cfloop list="#List_selectbuyName#" index="ListElement"
delimiters="¬">
<cfif i EQ 1>
<cfset nextPlan=ListGetAt
(List_selectbuyName,i,"¬")>
<cfset nextPlan_r=Replace(nextPlan,",","-
","ALL")>
<cfset valueTextList= nextPlan_r & "¬ " &
nextPlan_r & "^">
<cfelse>
<cfset nextPlan=ListGetAt
(List_selectbuyName,i,"¬")>
<cfset nextPlan_r=Replace(nextPlan,",","-
","ALL")>
<cfset valueTextList= ListAppend
(valueTextList, nextPlan_r & "¬ " & nextPlan_r, "^")>
</cfif>
<cfset i=i+1>
</cfloop>
<cfset valueTextList="0¬ All Buy Names loaded. Select a Buy
Name.^All¬ All^" & valueTextList>
<cfset valueTextList_conv=Replace(valueTextList,"¬",",","ALL")
>
<!--- Initialize Arrays --->
<cfset BuyNameArray = ArrayNew(1)>
<!--- Convert the List to an Array --->
<cfset BuyNameArray = ListToArray(valueTextList_conv,"^")>
<cfreturn BuyNameArray>
</cffunction>
<cfform method="post" name="Atlas" action="">
<table>
<tr>
<td>Plan Name:</td>
<td><select id="planName" name="planName" size="1"
onChange="getBuyNames();">
<option value="">Select Plan Name</option>
<cfoutput query="getplanName">
<option
value="#planName#">#planName#</option>
</cfoutput>
</select> </td>
</tr>
<tr>
<td>Buy Name:</td>
<td><select id="buyName" name="buyName" size="1"
onChange="getSiteNames();">
<option value=""></option>
</select></td>
</tr>
<tr>
<td>Site Name:</td>
<td><select id="siteName" name="siteName" size="1"
onChange="getPlacements();">
<option value=""></option>
</select></td>
</tr>
<tr>
<td valign="top">Placement:</td>
<td><select id="placementName" name="placementName"
multiple size="10">
<option value=""></option>
</select></td>
</tr>
</table>
</cfform>