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 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Doing an IF and ELSE in html

    Hi,

    I'm trying to figure out the code to have the user enter a simple password, have it verified, and if true redirect to a url. The password is the same for all users. It's doesn't lead to a sensitive place so I don't need encryption or unique passwords, or even user names. So I've gotten this far, but where the password condition is verified, I can't figure out how to code tags to automatically jump to a new url. In other words, where "else return true", I want to call a url to open.

    Thanks very much, Dave

    ............................
    Here's some of the code I have so far (AND I INDICATED WHAT I BELIEVE THE PROBLEM SPOT IS BY WRITING A LITERAL IN CAPS AFTER --ELSE RETURN TRUE--):


    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
    <HTML>
    <HEAD>
    <META NAME="Generator" CONTENT="TextPad 4.4">
    <LINK href="general.css" rel="stylesheet" type="text/css">
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Original: Carey Walker (carey.walker@citicorp.com) -->

    <!-- Begin
    function checkPw(form) {
    pw1 = form.pw1.value;


    if (pw1 != "1012cherry") {
    alert ("\nPassord incorrect. Please re-enter.")
    return false;
    }
    else return true;

    <!-- WHERE PW1 == "1012CHERRY", I WANT TO GO TO HTTP:\\WWW....ETC -->



    }



    // End -->
    </script>

    </HEAD>

    <BODY Background=../graphics/grayback.jpg>
    <center><BR><BR><BR>
    <form onSubmit="return checkPw(this)">

    <table border=0>
    <tr>
    <td>Password:</td><td><input type=text name=pw1 size=10></td>
    </tr>

    <tr>
    <td colspan=2 align=center><input type=submit value="Submit!"></td>
    </tr>
    </table>
    </form>

    </center>



    </BODY>
    </HTML>

  • #2
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,958
    Thanks
    120
    Thanked 76 Times in 76 Posts
    Code:
    window.location = ......

  • #3
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, I tried with that but I guess I can't figure out where open.window should be placed b/c I get no response the way I put it in.

  • #4
    Regular Coder
    Join Date
    Mar 2008
    Posts
    136
    Thanks
    39
    Thanked 1 Time in 1 Post
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
    <HTML>
    <HEAD>
    <META NAME="Generator" CONTENT="TextPad 4.4">
    <LINK href="general.css" rel="stylesheet" type="text/css">
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Original:  Carey Walker (carey.walker@citicorp.com)  -->
    
    <!-- Begin
    function checkPw() {
    var pw1 = document.getElementID("passwordField").value;
    
    if (pw1 != "1012cherry") {
    alert ("Passord incorrect. Please re-enter.")
    }
    else if (pw1 == "1012cherry") {
    window.open("http://www.example.com");
    }
    
    // End -->
    </script>
    
    <!-- HTML area: -->
    
    <label for:"password">Password: </label>
    <input id="passwordField" type="password" /><br>
    <input id="submit" type="button" onclick="checkPw()" />
    Try this. Get rid of the table and replace it with the HTML I provided.

    Edit: I'm not familiar with HTML 3.2 so I don't know whether my HTML is appropriate. Why not use XHTML 1.0? Or HTML 4.01?
    Last edited by webguy08; 04-03-2009 at 11:22 PM.

  • #5
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks a great deal webguy. I was able to work with the code you provided to make it all fit. I'm real rusty with HTML, haven't touched it for ten years, so I don't even know about the new formats and versions.
    Thanks again,
    ww

  • #6
    Senior Coder
    Join Date
    Oct 2005
    Posts
    1,340
    Thanks
    0
    Thanked 61 Times in 60 Posts
    HTML 3.2 died in the 1990s. wtf is someone doing raising that from the dead again? Use HTML4.01 strict only.

    Also, there is no such thing as "language=javascript". Change it to what it's supposed to be, "type=text/javascript".


  •  

    Posting Permissions

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