Can you try this (never try it by myself)

$('#edit-field-city-value > option:not(first-child)').remove();
for (var key in your_json_object) {
    $('#edit-field-city-value').append('<option value="' + key + '">' +
your_json_object[key] + '</option>');
}

On Wed, Nov 4, 2009 at 4:06 AM, Tan <[email protected]> wrote:

> Hi, all.
> I have two listbox:
> a listbox country
> <select id="edit-field-country-value" class="form-select" name="country
> [value]">
> <option selected="selected" value="">  - None -</option>
> <option value="1">Malaysia</option>
> <option value="2">Thailan</option>
> </select>
> a listbox city
> <select id="edit-field-city-value" class="form-select" name="field_city
> [value]">
> <option selected="selected" value="">  - None -</option>
> </select>
>
> When i select country then i use ajax response data { "1": "Quan 1",
> "2": "Quan 2", "3": "Quan 3", "4": "Quan 4" }
> 1, 2, 3,4 is key of array
> I want when select country then add key and values  of Json in listbox
> city
> Please help me
>

Reply via email to