Problem with comparing value with array values

Posted by Java starter on Stack Overflow See other posts from Stack Overflow or by Java starter
Published on 2010-04-11T14:21:20Z Indexed on 2010/04/11 14:43 UTC
Read the original article Hit count: 212

Filed under:
|

This code is what I use now. But it does not work when I try to use an array to compare values. If anybody has any idea of why, please respond.

<html>
 <head>
  <script type-'text/javascript'>

   function hovedFunksjon()
    {
     //alert("test av funksjon fungerte");
     //alert(passordLager);
     window.open("index10.html","Window1","menubar=no,width=430,height=360,toolbar=no");
    }

   function inArray(array, value) {
    for (var i = 0; i < array.length; i++) {
     if (array[i] == value) return true;
      }
       return false;
      }

   function spørOmPassord()
    {
     var passordLager = ["pass0","pass1","pass2"];

     window.passordInput = prompt("password");//Ved å bruke "window." skaper man en global variabel

     //if (passordInput == passordLager[0] || passordLager[1] || passordLager[2])
     if (inArray(passordLager,passorInput) )

      {
       hovedFunksjon();
      }
     else
      {
       alert("Feil passord");
       //href="javascript:self.close()">close window
      }
    }
   function changeBackgroundColor()
    {
     //document.bgColor="#CC9900";
     //document.bgColor="YELLOW"
     document.bgColor="BLACK"
    }
  </script>
 </head>

 <body>
  <script type-'text/javascript'>
   changeBackgroundColor(); 
  </script>
   <div align="center">
    <form>
     <input type = "button" value = "Logg inn" onclick="spørOmPassord()">
    </form>
   </div>
 </body>
</html>

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about array