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
You can use linq
content_login = Enumerable.From(data)
.Where(function (x) {
var Name = x.getElementsByTagName("UserName")[0].childNodes[0].nodeValue;
return Name == userName && Pass == Password; //If condition true it will execute Select
})
.Select(function (x) {
return Fields;
}).ToString();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.