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);
        });
    }

Leave a Comment

Your email address will not be published. Required fields are marked *