Click here to Skip to main content
15,884,472 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to load the select (drop down list) with data from xml file.
this code is to load xml file:

JavaScript
x = xmlDoc.getElementsByTagName("User");


"User" is the tag i want to catch if i found it, then update inter subTages 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.

JavaScript
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. önchange = 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("Typ").value = document.getElementsByTagName("Typ")[0].childNodes[0].nodeValue;
                  }
              }
          }


Thanks
Posted
Comments
n.podbielski 19-Nov-12 13:17pm    
Just try from root node and try work yourself down through tree selecting desired data. I do that and this always work. Besides how can we help you with anything not knowing XML scheme?
Did you even thought this through?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900