SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard Anat's Avatar
    Join Date
    Oct 2000
    Posts
    1,281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Can this be done with a javascript?

    Here's what I'm looking for:

    A small form that asks the visitor for some word or number (the answer to which they get elsewhere - it's part of a riddle kind of game I am having on my site).

    User types in the word or number and hits "submit". If it matches the right answer then he is taken to a certain URL (where the game continues). If it's not the right answer then he is taken to some other page where I will tell him to try again.

    I don't know any javascript. I want to look this up in free javascript directories. Can you please tell me if javascript can do this at all? If so what keywords am I looking for?

    Thanks!
    My Web Publishing Blog: B6S.net - I dofollow but don't spam!
    Follow me on Twitter
    My favorite content writer:
    Steve Snedeker

  2. #2
    SitePoint Guru dale_burrell's Avatar
    Join Date
    Aug 2002
    Location
    Wellington, New Zealand
    Posts
    861
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Something like this should do the trick.

    <!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title> New Document </title>
    <script>
    function CheckAnswer()
    {
    var Answer = document.getElementById("answer");

    if(Answer.value == "Secret")
    {
    location.href = "correctpage.html"
    }
    else
    {
    location.href = "failpage.html"
    }
    }
    </script>
    </head>

    <body>

    <form onSubmit="CheckAnswer(); return false;">
    <input id="answer" name="answer" type="text"/>
    <input type="submit" value="Go!">
    </form>

    </body>
    </html>
    If you aren't living life on the edge
    - you're taking up too much space
    Creative Dreaming Ltd / Ask The Local / Amanzi Travel

  3. #3
    SitePoint Wizard Anat's Avatar
    Join Date
    Oct 2000
    Posts
    1,281
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you!!!

    Once I had it I managed to make some slight modifications and it's working just as I wanted it to now!

    Thank you!
    My Web Publishing Blog: B6S.net - I dofollow but don't spam!
    Follow me on Twitter
    My favorite content writer:
    Steve Snedeker


Bookmarks

Posting Permissions

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