1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

I can't work this out- Help Please

Discussion in 'Web Development & Web Hosting' started by dee1810, Aug 7, 2006.

  1. dee1810

    dee1810 Byte Poster

    142
    2
    29
    Why doesn't this work, please?

    Code:
    <script language = "JavaScript">
    <!--
    var passWord;
    prompt ( "What is the password?","");
    (passWord == "pass" ) ? alert("Verified"): alert("Incorrect
    password");
    //-->
    
    </script>
     
    Certifications: Foundations, Site Designer & JavaScript
    WIP: Server Admin, and Perl
  2. r.h.lee

    r.h.lee Gigabyte Poster

    1,011
    52
    105
    dee1810,

    Instead of...

    prompt ( "What is the password?","");

    Try

    passWord = prompt ( "What is the password?", "");


    Source:
    1. Educational JavaScripting:More Simple Javascript - http://www.math.grin.edu/~rebelsky/Tutorials/JavaScript/EdMedia97/more.html
     
    Certifications: MCSE, MCP+I, MCP, CCNA, A+
    WIP: CCDA
  3. hbroomhall

    hbroomhall Petabyte Poster Gold Member

    6,623
    115
    224
    In addition - you have the script code in a comment - so it won't run.

    A small point: <script language = is deprecated - use <script type =. (This won't stop it from working in FF though).

    Harry.
     
    Certifications: ECDL A+ Network+ i-Net+
    WIP: Server+
  4. JonnyMX

    JonnyMX Petabyte Poster

    5,239
    211
    236
    Try creating an ASP page and using this, or something like it...

    Code:
    <%
    Username="USER"
    Password="PASSWORD"
    ' if any of the variables do not match, create error message
    if Request.Form("login") <> Username or Request.Form("password") <> Password then
        MsgErr = "<h3>You are not logged in</h3>"
        Response.Write MsgErr
        ' if correct, set the session variable and proceed
    Else
        Session("someStringValue") = true
        ' redirect
        If Len(Request("requester")) > 0 Then
            Response.Redirect (Request("requester"))
        Else
            Response.Redirect "protected.asp"
        End if
    End if
    %>
     
    Certifications: MCT, MCTS, i-Net+, CIW CI, Prince2, MSP, MCSD
  5. dee1810

    dee1810 Byte Poster

    142
    2
    29
    Hey

    Thanks Guys.
    JonnyMX- oh, wow. That looks very tricky.. i'll get my head on before I struggle with that :eek:

    Harry- About the comments.. I know what you mean, but I understood that the comments aren't like HTML comments that aren't visible when the page loads into a browser, but the comments in JavaScript are purely for browsers that are not JavaScript -enabled. Plus, I didn't realise that script language is deprecated Cheers

    r h Lee. Thank You.. I can see your hint will work...Cheers again.

    Dee1810
     
    Certifications: Foundations, Site Designer & JavaScript
    WIP: Server Admin, and Perl

Share This Page

Loading...