in Code Snippet, Javascript

Populate Dropdown with Javascript

actually still with jquery.

populateDrodpdown(id, container) {
        let _this = this
        let dropdown = $('#' + container);
        dropdown.empty();       

        fetch(baseUrl + 'someGet/' + id)
        .then((response=> {
            return response.json();
        })
        .then((data=> {
            $.each(datafunction (key, data) {
                dropdown.append($('<option></option>').attr('value', data.id).text(data.name));
            })
            dropdown.prop('selectedIndex', 0);
        });
    }

Write a Comment

Comment