• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Bind from cfselect into input

Guest
Aug 19, 2007 Aug 19, 2007

Copy link to clipboard

Copied

I have got this cfselect that returns a query.
<cfselect name="mediaid#AllMeals.Id#" bind="cfc:Foods.getAllFoods()" VALUE="Id" DISPLAY="Name" bindonload="true" />

Now when I make a selection I would like to fire another cfc that returns all the specifications for the item choosen.

I have tried to do it like this
<CFINPUT TYPE="Text" NAME="FoodId" SIZE="4" BIND="cfc:Foods.GetFood({mediaid#AllMeals.Id#})" >
But it returns a single query result and outputs [object Object] in the input field.

What I want is the id printed out here and the in another area I would print another item out a.s.o.

How do I do that?
TOPICS
Advanced techniques

Views

311

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Aug 20, 2007 Aug 20, 2007
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=...

Votes

Translate

Translate
Guest
Aug 20, 2007 Aug 20, 2007

Copy link to clipboard

Copied

LATEST
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);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation