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 7 of 7
  1. #1
    Regular Coder
    Join Date
    Apr 2010
    Posts
    118
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Force click in the wrong place

    I'm looking to make a series of joke questions. I'm struggling on one of them. I want to have two options, but when the user tries to click on the obvious answer, the button next to it is clicked.

    The BEST way for this to happen, is that when the user clicks down on the correct answer, the mouse moves 100px to the right to complete the click on the wrong answer. (As if the user has accidentally flicked the mouse to the right whilst clicking.)

    I've heard that onmousedowns are implemented before onclicks, so I've been trying to make that work but I'm not getting far. I've also tried hover/CSS effects but they aren't as good. They are great for things like this:

    http://www.romneytaxplan.com/

    But not for making someone click the wrong thing. Any ideas?

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,734
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    That is not possible - it would be a huge security risk and offer the possibility that a user who clicks "No thank you" is in fact made to click "Yes please".
    Or worse - perhaps a link to a malware site.

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Ummm...why not something as simple as this?
    Code:
    <!DOCTYPE html>
    <html>
    <body>
    <form>
    Would you like $1,000,000?<br/>
    <label><input type="radio" name="joke"
                  onclick="var b=this.form.joke[1];b.checked=true;b.focus();"
    /> YES!</label>
    <label><input type="radio" name="joke"/> No, I'm too rich already</label>
    </form>
    </body>
    </html>
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #4
    Regular Coder
    Join Date
    Apr 2010
    Posts
    118
    Thanks
    6
    Thanked 0 Times in 0 Posts
    That's cool idea old pendant, I'd never seen that sort of twist before! I can see that being really annoying.

    But for this one, it needs to look like the user's mouse fault, not a broken form. Also, it needs to click down on the wrong link so that it goes through to the next question.

    Each question is on a different page.

  • #5
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Moving the focus() should produce the same effect.

    It doesn't show up well on radio buttons, but I bet we could make it look better:
    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <style type="text/css">
    .noninput {
        border: none;
    }
    </style>
    </head>
    <body>
    <form>
    Would you like $1,000,000?<br/>
    <label>
        <input type="radio" name="joke"
               onclick="this.form.joke[1].checked=true;this.form.funny.focus();"
        /> 
    YES!</label>
    <label>
        <input type="radio" name="joke"/>
        <input class="noninput" name="funny" value="No, I'm too rich already."/>
    </label>
    </form>
    </body>
    </html>
    That's better. More confusing, for sure.

    But let me try some more.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #6
    Regular Coder
    Join Date
    Apr 2012
    Location
    St. Louis, MO
    Posts
    985
    Thanks
    7
    Thanked 101 Times in 101 Posts
    Somewhere, out in the vast reaches of the inernet, is a script that will cause an element to quickly move away, as soon as the element detects mousedown. Someone sent me a link to the site, a LONG time ago. Caught me off guard, for sure. If you could apply that to the radio button that is the correct answer (leaving the incorrect answer alone), that'd be a chuckle, or two.
    ^_^

    If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
    *
    The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

  • #7
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Ahhh....look at this answer!
    http://stackoverflow.com/questions/4...sor-javascript

    CUTE!

    And not hard to do.

    In your case, don't hide the cursor until the button is clicked.
    Then hide the real cursor and have your fake one appear 200px to the right (or wherever) of the real one and start tracking the real one for a while.

    Since you will be going to another page (or another spot on same page?), you let the real cursor appear after the click on the wrong link is simulated.

    It would help to show some real HTML code as it is on your page.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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