# Combo box and change handler - in over my head

**URL:** <https://forum.kirupa.com/t/combo-box-and-change-handler-in-over-my-head/38414>\
**Category:** Uncategorized\
**Created:** [December 22, 2003, 4:53pm UTC](https://forum.kirupa.com/t/combo-box-and-change-handler-in-over-my-head/38414 "2003-12-22T16:53:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lunatic](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@lunatic](https://forum.kirupa.com/u/lunatic)\
**Post date:** [December 22, 2003, 4:53pm UTC](https://forum.kirupa.com/t/combo-box-and-change-handler-in-over-my-head/38414/1 "2003-12-22T16:53:58Z")

</div>

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? 😃

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 22, 2003, 6:47pm UTC](https://forum.kirupa.com/t/combo-box-and-change-handler-in-over-my-head/38414/2 "2003-12-22T18:47:47Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 22, 2003, 6:55pm UTC](https://forum.kirupa.com/t/combo-box-and-change-handler-in-over-my-head/38414/3 "2003-12-22T18:55:56Z")

</div>

Brilliant!

Thanks pom!! :love:
