I'm havving troubles filling in a dropdown list with values passed back via AJAX.
function city_list (form_id, list_id)
{
if(httpObject.readyState == 4)
{
var cities = httpObject.responseText;
for (i=0; i<cities.length-1; i++)
{
var city = cities[i].split(":");
document.form_id.list_id.options[document.form_id.list_id.options.length] = new Option (city[1] , city[0]);
}
}
}
This does not work, however when I manualy type in the form_id and the list_id it works.
So if the form_id = city_form, list_id = city_names
changing the line
document.form_id.list_id.options[document.form_id.list_id.options.length] = new Option (city[1] , city[0]);
to
document.city_form.city_names.options[document.city_form.city_names.options.length] = new Option (city[1] , city[0]);
it works. How can I get the first example to work, I want to pass the form and list info to the function.