I want to load the select control (drop down list) with data from an xml file. This is the code to load the xml file:
x = xmlDoc.getElementsByTagName("User");
"User" is the tag i want to catch if i found it, then update into sub-tags like: "UserName","Password","Type". After catch "User" update depending on select.selected. Update "Password" will be from Textbox. Update "Type" will be from select. This is the code i write but it doesn't get my output, any one could help by new code or edit my code.
var select = document.getElementById("updater");
for (i = 0; i < x.length; i++) {
select.options[select.options.length] = new Option(
x[i].getElementsByTagName("UserName")[0].childNodes[0].nodeValue,
x[i].getElementsByTagName("UserName")[0].childNodes[0].nodeValue);
}
select.onchange = function update() {
for (i = 0; i < x.length; i++) {
if (document.getElementById("updater").value = x[i].getElementsByTagName("UserName")[0].childNodes[0].nodeValue)) {
document.getElementById("password").value = document.getElementsByTagName("Password")[0].childNodes[0].nodeValue;
document.getElementById("Type").value = document.getElementsByTagName("Type")[0].childNodes[0].nodeValue;
}
}
}
Thank you