Friday, November 6, 2009

[jQuery] Re: Fill key va value from response of Json { "1": "Quan 1", "2": "Quan 2", "3": "Quan 3", "4": "Quan 4" } in listbox.

Thanks Dang Vu. It's work.

On Nov 4, 7:41 pm, Thai Dang Vu <tdan...@gmail.com> wrote:
> 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 <it_qn2...@yahoo.com> 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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate