avair
May 30, 2023, 7:19 PM
Below is the javascript function which i am using to bind values to the dropdown using ddlCou.innerText = option.text; only the last option is getting displayed as a label but i need to have a dropdown functionality with select at first and remaining all values which are in result[i]
function loadCountriesDropDown() {
var ddlCou = document.getElementById('ddlCountriesId');
var countyStates = [];
for (var i = 0; i < data.List.length; i++) {
countyStates.push(data.List[i].Name);
}
var result = countyStates.map(function (obj) { return obj.Name; });
result = result.filter(function (v, i) { return result.indexOf(v) == i; });
for (var i = 0; i < result.length; i++) {
var option = document.createElement("option");
option.text = result[i];
ddlCou.innerText = option.text;
}
}
<ext:ComponentColumn runat="server">
<Items>
<ext:DropDownField runat="server" ID="ddlCountriesId" ClientIDMode="Static"></ext:DropDownField>
</Items>
</ext:ComponentColumn>
function loadCountriesDropDown() {
var ddlCou = document.getElementById('ddlCountriesId');
var countyStates = [];
for (var i = 0; i < data.List.length; i++) {
countyStates.push(data.List[i].Name);
}
var result = countyStates.map(function (obj) { return obj.Name; });
result = result.filter(function (v, i) { return result.indexOf(v) == i; });
for (var i = 0; i < result.length; i++) {
var option = document.createElement("option");
option.text = result[i];
ddlCou.innerText = option.text;
}
}
<ext:ComponentColumn runat="server">
<Items>
<ext:DropDownField runat="server" ID="ddlCountriesId" ClientIDMode="Static"></ext:DropDownField>
</Items>
</ext:ComponentColumn>