PDA

View Full Version : loadvars & comboBox


vosgien
10-29-2002, 03:03 PM
Hi,
I'm not sure where this query should be AS, MX or....
I have done a search under the thread title and came up with a response by tg, which was in fact like a mini tute, unfortunately, it doesn't go quite far enough.

I want to load a list of countries from a txt file into a comboBox,
so far I have this code :

myCountries = new LoadVars();
myCountries.onLoad = addCountries;
myCountries.load("Countries.txt");

function addCountries() {
for (var i=0; i<myCountries.numCountries; i++) {
resident.addItem(Countries[i]);
}
}

All I am getting is a list of 27 commas ?
I wonder if the problem may be in the text file, as the countries will also link to a web service fro exchange rate purposes, so the list in my txt file looks a bit like this :

&name0=United States&value0=usa&

and so on for 27 names

What should I change to load in the Countries.txt into my comboBox, and will I need to create a seperate file for the currency conversion ?

Thanks

Vosgien

jimburton
10-29-2002, 03:32 PM
this might do it:


function addCountries(success) {
if (success) {
for (var i=0; i<this.numCountries; i++) {
_root.resident.addItem(this["name"+i], this["value"+i]);
}
} else {
//it's worth checking that they're loaded...
}
}


any help?

vosgien
10-29-2002, 03:36 PM
Thanks Jim, it worked a treat

Vosgien