Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

bind json data to dropdownlist using javascript

// THE JSON ARRAY.
var birds = [
  {"ID": "001", "Bird_Name": "Eurasian Collared-Dove"},
  {"ID": "002", "Bird_Name": "Bald Eagle"},
  {"ID": "003", "Bird_Name": "Cooper's Hawk"},
];

var dropDown = document.getElementById('dropdown-id');
for (var i = 0; i < birds.length; i++) {
  // POPULATE SELECT ELEMENT WITH JSON.
  ele.innerHTML += '<option value="' + birds[i]['ID'] + '">' + birds[i]['Bird_Name'] + '</option>';
}
 
PREVIOUS NEXT
Tagged: #bind #json #data #dropdownlist #javascript
ADD COMMENT
Topic
Name
3+5 =