3.2.0

¿Options of combobox2 depend on value selected of combobox1?

/* in English */
how I can create two combobox employees for when it selects an option in combobox1, in combobox2 they appear the data related to the value selected in first combobox

note: the information of combobox2 is due to obtain with ajax

I hope for your help.
thanks


/* en Español */
como creo dos combobox dependientes para cuando seleccione una opcion en el combobox1, en el combobox2 aparezcan los datos relacionados con el valor seleccionado en el primer combobox

nota: la informacion del combobox2 se debe de obtener con ajax

espero por tu ayuda.
gracias


Alain. Havana. Cuba
May 16,
Alex,
Would you please comment on this question?

Thanks
Alain
May 16,
You should listen to validation event on the first combo and load the list of items into the second one -

combo1.onControlValidated = function(text){
  var arrayOfItems = getItemsWithAjax(text);
  combo2.setItemText(arrayOfItems);
  combo2.setItemCount(arrayOfItems.length);
}
Alex (ActiveWidgets)
May 16,
Thancks a lot Alex, but I have another question: How can i get the value of the item selected in combo1?.
It could be something like this?
combo1.onControlValidated = function(value){
  var result = getItemsWithAjax(value);
// resutl = [{city:{text:"havana",valor:1}},{city:{text:"varadero",valor:2}}];  
  combo2ItemText = new Array();
  combo2ItemValue = new Array();
  for(i=0; i<result.lentgh; i++){
      combo2ItemText[i] = result[i].city.text;
      combo2ItemValue[i] = result[i].city.value;
  }

  combo2.setItemText(combo2ItemText);
  combo2.setItemValue(combo2ItemValue);
  combo2.setItemCount(result.length);
}


Alain
May 16,
Alex, then is correct what I exposed previously?
Alain
May 16,

This topic is archived.

See also:


Back to support forum