Im trying to populate a dropdown list created in HTML with data i am matching from an XML file.
At the moment I can read the XML file and get the matching data i want using a javascript function and display the variable in an Alert window for debugging purposes.
However, I am unsure how to bind each piece of matching data to the dropdown list.
Below is the XML searching Function showing the alert popup and the variable "name", I want to display each entry of "name" as n option in the dropdownlist.
if (xmlDoc != null) {
var restaurants = new Array();
var x = xmlDoc.getElementsByTagName("Units");
for (i = 0; i < x.length; i++) {
if (x[i].getElementsByTagName("Type")[0].childNodes[0].nodeValue == "Container" ) {
if (x[i].getElementsByTagName("Allocated")[0].childNodes[0].nodeValue == "YES" ) {
var name = x[i].getElementsByTagName("Name")[0].childNodes[0].nodeValue;
var telnumber = x[i].getElementsByTagName("Allocated")[0].childNodes[0].nodeValue;
alert("Found "+name);
}
}
And here is my HTML dropDownlist populate with one "default" entry.
<select id="myDropDown" style="width: 95%; border-radius:8px; border:1px solid #AAAAAA;"><option value="default">Default</option></select>
Im just not sure how to get my "name" variable in there and populate a list.
Any help would be appreciated.