PDA

View Full Version : Combo boxes that affecting each other


chrisfromcanada
01-08-2008, 08:11 PM
I am trying to make a combo-box populated form which allows the user to narrow down the info based on Country, then State/Province, then City. (So 3 boxes total with the City one being the one that calls the info into a dynamic txtbox.

Right now here's my code. I'm loading vars from the following text file (dealer.txt):

&clst=Canada,USA
&canlst=Ontario,Alberta,Manitoba,British Columbia
&usalst=New York,Ohio,Pennsylvania

I'm loading them with:

loadVariablesNum("dealer.txt",0);

The first combobox, named "countrybox" is populated using the following:

stop();
clstarr = clst.split(",");
j = clstarr.length;

for (i=0; i<j; i++) {
nmt = clstarr[i];
countrybox.addItem(nmt);
}

and it all works fine. However I want that box to populate the next one (named "regionbox") once the user makes their selection in "countrybox". So I've come up with this code which is placed on the actions of countrybox:


on(change) {
countryV = _parent.countrybox.getValue();
if (countryV == "Canada") {
canlstarr = canlst.split(",");
j = canlstarr.length;
for (i=0; i<j; i++) {
nmt = canlstarr[i];
regionbox.addItem(nmt);
}
}


else if (countryV != "Canada") {

usalstarr = usalst.split(",");
j = usalstarr.length;
for (i=0; i<j; i++) {
nmt = usalstarr[i];
regionbox.addItem(nmt);
}


}
}

So obviously (to you perhaps, not me!) this last bit of code isn't working, but I don't know why. The exact same code works fine if I link it to a simple button next to the comboboxes...

What am i missing?