First newbie Javascript

Discussion in 'General Programming Chat' started by RuleTheWorld, Jul 9, 2009.

  1. RuleTheWorld

    RuleTheWorld Junior Member

    Joined:
    Jul 7, 2009
    Messages:
    108
    Likes Received:
    24
    Occupation:
    I currently work in a Supermarket - i'll change th
    Location:
    Queensland, Australia.
    I've been learning JavaScript for about an hour now and i have made a little login script to run on a website. It works pretty well so far, what do you guys think?

    Code:
    var passwordcheck
    var usernamecheck
    var username=prompt("Enter your username: ", "");
    if (username == "chris")
        {
            usernamecheck = 1;
        }
    else
        {    
            usernamecheck = 0;
        }
    var password=prompt("Enter your password: ", "");
    if (password == "chris")
        {
            passwordcheck = 1;
        }
    else
        {
            passwordcheck = 0;
        }
    if (usernamecheck == 1 && passwordcheck == 1)
        
    {
            document.write("<center><h1>Welcome back, Chris.</h1> \n <h2>You have full access to this Control Panel.</h2></center>");
        }
    else if (usernamecheck == 0 && passwordcheck == 1)
        
    {
            alert("Your username is false!");
        }
    else if (usernamecheck == 1 && passwordcheck == 0)
        
    {
            alert("Your password is false!");
        }
    
    
     
  2. RuleTheWorld

    RuleTheWorld Junior Member

    Joined:
    Jul 7, 2009
    Messages:
    108
    Likes Received:
    24
    Occupation:
    I currently work in a Supermarket - i'll change th
    Location:
    Queensland, Australia.
    Sorry, this is in the wrong section. I didn't see the scripting section (possibly because it's 3 in the morning).