title: Need help with authenticating a usrname & pswd through an array in javascript
body: <p>Hi Everyone <br>
  The question I'm asking is mainly on Javascript. First, I'm not very good with technical terms, so bear with me if I'm not that clear.<br>
  Anyway, my goal is to authenticate a login process, the username and password, where both argument exist in an array, which is populated by a XML file. Basically the array contains information from an XML file and the username &amp; password is also within that array. Inorder for a user to login, the username and password entered must be within the array or it returns an error message. My problem is that I'm not sure which syntax I am suppose to use when representing an index in the array and I'm not sure if the syntax I'm using is even correct. All I know is that it authenticated the first username and password in the array &amp; XML file, but everything else is treated as incorrect even if it is correct.</p>
  
  <p>Here's my Javascript file:</p>
  
  <pre><code>var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
  
  //DEFINE LOAD METHOD
  function LoadXML(xmlFile)
  {
   xmlDoc.load(xmlFile);
   xmlObj = xmlDoc.documentElement;
  }
  
  //declare &amp; initialize array
  var arrPerson = new Array()
  
  //initialize array w/ xml
  function initialize_array()
  {
  LoadXML("PersonXML.xml");
  var x = 0;
  while (x &lt; xmlObj.childNodes.length)
  {
      var tmpArr = new Array(xmlObj.childNodes(x).getAttribute("Usrname"), 
                             xmlObj.childNodes(x).getAttribute("Pswd"), 
                             xmlObj.childNodes(x).getAttribute("FirstName"), 
                             xmlObj.childNodes(x).getAttribute("LastName"), 
                             xmlObj.childNodes(x).getAttribute("DOB"),
                             xmlObj.childNodes(x).getAttribute("Gender"),  
                             xmlObj.childNodes(x).getAttribute("Title"));
      arrPerson.push(tmpArr);
      x++;   
  }
  }
  
  //Validation
  function LogInVal(objtxt)
  {
      if(objtxt.value.length == 0)
      {
          objtxt.style.background = "red";
          return 1;
      }
  
      else
      {
          objtxt.style.background = "white";
          return 0;
      }
  }
  
  //main validation
  function MainVal(objForm)
  {
      var errmsg = "empty field";
      var errmsg2 = "Incorrect Username and Password";
      var msg = "You have logged in successfully";
      var errCount = 0;
  
      var usrname1 = document.getElementById("usrname1").value;
      var pswd1 = document.getElementById("pswd1").value;
  
      errCount += LogInVal(objForm.usrname);
      errCount += LogInVal(objForm.pswd);
  
      if (errCount != 0)
      {
          alert(errmsg);
          return false;
      }
      else
      {
          initialize_array();
          for (x = 0; x &lt; arrPerson.length; x++) 
          {
              if (arrPerson[x][0] == usrname1 &amp;&amp; pswd1 == arrPerson[x][1])  //I think my problem is within here
              {
                  alert(msg);
                  return true;
              }
  
              else
              {
                  alert(errmsg2);
                  return false;
              }
          }
      }
  
  }
  </code></pre>
  
  <p>And here's my XML file:</p>
  
  <pre><code>&lt;?xml version ="1.0" encoding="utf-8" ?&gt;
  &lt;!--GGFGFGFVBFVVVHVBV--&gt;
  &lt;PersonInfo&gt;
    &lt;Person Usrname="Bob111" Pswd="Smith111" personid="111" FirstName="Bob" LastName="Smith" DOB="01/01/1960" Gender="M" Title="Hello1"&gt; 
    &lt;/Person&gt;
    &lt;Person Usrname="Joe222" Pswd="Johnson222" personid="222" FirstName="Joe" LastName="Johnson" DOB="12/01/1980" Gender="M" Title="Hello2"&gt;
    &lt;/Person&gt;
    &lt;Person Usrname="Tracey333" Pswd="Wilson333" personid="333" FirstName="Tracey" LastName="Wilson" DOB="12/01/1985" Gender="F" Title="Hello3"&gt; 
    &lt;/Person&gt;
    &lt;Person Usrname="Connie444" Pswd="Yuiy444" personid="444" FirstName="Connie" LastName="Yuiy" DOB="12/01/1985" Gender="F" Title="Hello4"&gt;
    &lt;/Person&gt;
    &lt;Person Usrname="Brian555" Pswd="Dame555" personid="555" FirstName="Brian" LastName="Dame" DOB="12/01/1985" Gender="M" Title="Hello5"&gt; 
    &lt;/Person&gt;
    &lt;Person Usrname="Scott666" Pswd="Bikes666" personid="666" FirstName="Scott" LastName="Bikes" DOB="12/01/1985" Gender="MF" Title="Hello6"&gt;  
    &lt;/Person&gt;
  &lt;/PersonInfo&gt;
  </code></pre>