1 Reply Latest reply on Aug 20, 2007 4:59 AM by kruse

    Bind from cfselect into input

    kruse Level 1
      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?
        • 1. Re: Bind from cfselect into input
          kruse Level 1
          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[x] + "\n";
          alert (temp);