Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2009
    Posts
    96
    Thanks
    11
    Thanked 0 Times in 0 Posts

    Exclamation Weird if statement problem

    Hi,

    I'm trying to use the below if statement to say if a typed in name does not equal the name I'm expecting, an alert is thrown up.

    But, the alert is thrown up even when I type in the correct name. Am I doing sth wrong?!

    if (uni_name != "Bournemouth University" ||
    uni_name != "British Universities Film and Video Council (BUFVC)" ||
    uni_name != "Cambridge Imaging Systems (CIS)" ||
    uni_name != "Glasgow Metropolitan College" ||
    uni_name != "Royal Holloway, University of London" ||
    uni_name != "University of Portsmouth") {
    alert("Sorry, the institution '" +uni_name+ "' was not recognised or does not have access to this service.");
    }

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,851
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Use the AND operator(&&) instead of ||

    See http://en.wikipedia.org/wiki/De_Morgan%27s_laws
    Last edited by abduraooft; 07-28-2009 at 10:56 AM.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •