I have a html dropdown list. On page load, I have to populate the values from a JSON.JS file using Jquery.
The JSON file contains:
var accounts = ["WHDH","TF"];
After the json.js has been added:
$(document).ready(function() { $('#myDropdown').empty(); // empty the dropdown (if necessarry) $(accounts).each(function(iIndex, sElement) { $('#myDropdown').append('<option>' + sElement + '</option>'); }); });
Also see this example.
1.4m articles
1.4m replys
5 comments
57.0k users