Take the 2-minute tour ×

how to get the fId of the selected fname??

Here's my code..

var fS = new Memory({   //store for the combo
    data: [
        {fN:"", fId:""}
var fCombo = new ComboBox({          //combo box
        id: "fCombo",
        name: "fCombo",
        value: "Select",            
        searchAttr: "fName"
    }, "fCombo");       
    fCombo.store = fStore;
    url: "XXX",
    handleAs: "json", 
    load: function(response, ioArgs){               
          fCombo.store.data = response.xx;
          return response; 
    error: function(response, ioArgs){
          console.log("Error", response+' '+ioArgs);
          return response;

dojo.connect(dijit.byId("fCombo"), 'onChange',function(e){
   //code to write based on f id

I tried this..

var Id = fStore.getValue(dijit.byId("fCombo").data, "fName");

But couldn't.. It says object doesn't supprt this propertty

Please help..!!

share|improve this question

1 Answer 1

up vote 2 down vote accepted

It's complaining because dijit.byId("farmCombo") returns the ComboBox, which doesn't support '.data'.

Instead of using 'connect', try using 'watch'. There are loads of things you can watch. 'value' will get you your pure value changes, but if you listen to 'item' changing, you'll get given the full old and new item, from which you can retrieve your item id.


farmCombo.watch("item", function(what, oldVal, newVal) {
  // selected farmid is newVal.farmId

Here's a sample which displays your selected id in a separate textbox:


If you don't specify which value to watch, your callback will show you all changes, which can be extremely useful.

share|improve this answer

Your Answer


