0

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

1 Answer 1

1

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();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.