I want to add the option into select combo box for example I have data like
[{ \"NAME\": \"JONE\", \"ID\": {\"id1\":123,\"id2\":124}}, { \"NAME\": \"ANGEL\", \"I
You can do it like the following:
Append the select element
var dropDown = d3.select("body").append("select")
.attr("name", "name-list");
Append options to your select element based on data
var options = dropDown.selectAll("option")
.data(data)
.enter()
.append("option");
Set the text and value for your options
options.text(function(d) {
return d.NAME;
})
.attr("value", function(d) {
return d.NAME;
});
JSFiddle - https://jsfiddle.net/x4a8ejk6/