Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: A box where if you type in the right word you will be redirected to another page

  1. #1
    Join Date
    Nov 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb A box where if you type in the right word you will be redirected to another page

    I'm working on website that will have riddles on it. It is kind of a game. If people find out the answer, they should be able to write it down in a box and press enter. If the answer was correct, they should be redirected to a new page with the next riddle. If the answer was wrong, either nothing should happen or it should say "Your answer was wrong, please try again" or something simular.

    Any idea on how I achieve this?

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    A slight modification to the "encrypted password" script should serve us.
    Code:
    <script type="text/javascript">
    //Encrypted Password script- By Rob Heslop
    // Modified by Twey to remove username field and check onchange.
    //Script featured on Dynamic Drive 
    //Visit http://www.dynamicdrive.com 
    
    function submitentry(field){
      var password = field.value.toLowerCase()
      var passcode = 1
      for(var i = 0; i < password.length; i++) {
        passcode *= password.charCodeAt(i);
      }
      //CHANGE THE NUMBER BELOW TO REFLECT YOUR PASSWORD
      if(passcode==126906300)
      //CHANGE THE NUMBER ABOVE TO REFLECT YOUR PASSWORD
        window.location=password+".htm"
    </script>
    <input type="password" onchange="submitentry(this);">
    Get your passcode from http://www.dynamicdrive.com/dynamicindex9/password.htm .
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Nov 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I tried it out with a test page:

    http://www.inspired.be/riddles/start.htm

    It doesn't seem to work. Can someone take a look and see why it's not working?

    When people got the word wrong it should say "It looks like you got the wrong answer!". But it doesn't do anything. If you answer right, it doesn't do anything right either.

    For those who want to test it, the answer should be ebay.
    Last edited by Inspired; 11-08-2005 at 02:09 PM.

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Change:
    Code:
      <input type="button" value="Submit" onClick="submitentry()">
    to:
    Code:
      <input type="button" value="Submit" onClick="submitentry(this.form.level)">
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #5
    Join Date
    Nov 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I have changed the line and still doesn't do a thing.

    The changed page can still be found here:
    http://www.inspired.be/riddles/start.htm

  6. #6
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Ahaha, that was stupid. I was assuming you'd put the elements in a form. Either put them in a form, or use:
    Code:
    document.getElementsByName("level")[0]
    instead of this.form.level.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #7
    Join Date
    Nov 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I changed it, but it's still not responding.

  8. #8
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Firstly, I did something stupid again. Secondly, you didn't do what I said.
    Your onclick event looks like this:
    Code:
    onClick="submitentry(document.getElementsByName("level)[0])
    which compares badly to my:
    Code:
    onclick="submitentry(document.getElementsByName("level")[0])"
    which ought to be:
    Code:
    onclick="submitentry(document.getElementsByName('level')[0])"
    (single quotes instead of double quotes).
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  9. #9
    Join Date
    Nov 2005
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey
    Firstly, I did something stupid again. Secondly, you didn't do what I said.
    Your onclick event looks like this:
    Code:
    onClick="submitentry(document.getElementsByName("level)[0])
    You must have looked wrong, because it is

    Code:
      <input type="button" value="Submit" onClick="submitentry(document.getElementsByName("level")[0])">
    Just like your code. I basicly copied and paste it, so I don't know why it shows any different at your computer.

    Quote Originally Posted by Twey
    which ought to be:
    Code:
    onclick="submitentry(document.getElementsByName('level')[0])"
    (single quotes instead of double quotes).
    Thank you It finally works. I really appreciate all the help you gave me.

    I only have one practical question, how hard is it to crack this code? Are they online coverters that would make it able for users to cheat?

  10. #10
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    It's quite tricky to crack, I believe, though far from invulnerable. It can't just be decrypted, as it's a very simple has algorithm. However, bruteforcing probably wouldn't take too long (comparatively - we're talking days here). If anyone's that desperate to crack your little puzzle, however, you really shouldn't be using client-side scripting
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •