It is amazing what you can find out if you try it
I have now found out how to perform thi by using the
cfajaxproxy.
<CFAJAXPROXY CFC="cfc.Foods" JSCLASSNAME="FoodsProxy">
And the javascript
var MyFoodsProxy = new FoodsProxy();
function getMealDetails(id,out) {
var foodId = id.value;
var result = MyFoodsProxy.getFood(foodId)
var objID = eval("document.DataForm.foodId_" + out);
objID.value = result.ID;
}
And the field to recieve the result
<CFINPUT NAME="foodId_#AllMeals.Id#"
ID="foodId_#AllMeals.Id#" SIZE="2" READONLY="true">
I tried to use a div and span but I could not get this to
work.
And atlast the select that fires the javascript
<cfselect name="foodName_#AllMeals.Id#"
bind="cfc:Foods.getAllFoods()" VALUE="Id" DISPLAY="Name"
bindonload="true"
ONCHANGE="getMealDetails(foodName_#AllMeals.Id#,#AllMeals.Id#)
The cfajaxproxy is a very usefull tag and I think that I will
be using this alot in the future. You get a functionality that is
simular to FLEX but without the preload time (starting flash).
Remember that the cfc should return a Structure and not a
Query.
I did make this javascript that can printout the details of a
javascript object.
ret = result;
obj = eval(ret);
var temp = "";
for (x in obj)
temp += x + ": " + obj
+ "\n";
alert (temp);