Combo box and change handler - in over my head

Howdy all,

Anyone know how I can set the data in my combo box = the name of a textfile to be loaded into a dynamic textbox?

I am trying a combo box for the first time. I’ve used AS to load it but am now having trouble with the ChangeHandler function. I only have a couple of items in the combo box and I am using them to load dynamic text files. I am using the following code that I adapted from another thread I found. “sort” is the instance name of my combo box. MCtxt is the name of my dynamic text box:

[AS]
// change handler callback
function textSort(filename) {
loadText = new LoadVars();
loadText.load(filename);
loadText.onLoad = function(success) {
if (success) {
_root.MCtxt.html = true;
_root.MCtxt.htmlText = this.sortMC;
}
};
}
// data provider
var filename = sort.getSelectedItem().data;
var data_array = new Array();
// first item
data_array[0] = {label:“Sort documents”, data:""};
// second item
data_array[1] = {label:“By Date”, data:“documents/sort_date.txt”};
// third item
data_array[2] = {label:“By Type”, data:“documents/sort_type.txt”};
// set data provider
sort.setDataProvider(data_array);
// set change handler
sort.setChangeHandler(“textSort”);
[/AS]

I can’t figure out how to set “filename” = to the data_array. Can anyone help? :smiley:

Maybe if you get the filename from within the function:[AS]// change handler callback
function textSort© {
var filename = c.getSelectedItem().data;
loadText = new LoadVars();
loadText.load(filename);
loadText.onLoad = function(success) {
if (success) {
_root.MCtxt.html = true;
_root.MCtxt.htmlText = this.sortMC;
}
};
}
// data provider
var data_array = new Array();
// first item
data_array[0] = {label:“Sort documents”, data:""};
// second item
data_array[1] = {label:“By Date”, data:“documents/sort_date.txt”};
// third item
data_array[2] = {label:“By Type”, data:“documents/sort_type.txt”};
// set data provider
sort.setDataProvider(data_array);
// set change handler
sort.setChangeHandler(“textSort”);
[/AS]pom :slight_smile:

Brilliant!

Thanks pom!! :love: