Misusing the reset-button into submission

Discussion in 'Javascript' started by Evertjan., Feb 8, 2012.

  1. Evertjan.

    Evertjan. Guest

    Misusing the reset-button into submission is fun

    <form onreset='this.submit()'>

    is enough.

    Changing the action-url is easy:

    <form
    onreset='this.action="another.html";this.submit()'
    >


    However detecting which button was pressed
    takes some more action:

    ===============
    <script type='text/javascript'>
    function which(t) {
    t.form.whichButton.value=t.value;
    };
    </script>

    <form
    onsubmit='this.action="a.html";'
    onreset='this.action="b.html";this.submit()'
    >

    <input name='z'>
    <input type='submit' value='submit 1 to a' onclick='which(this);'>
    <input type='submit' value='submit 2 to a' onclick='which(this);'>
    <input type='reset' value='submit 1 to b' onclick='which(this);'>
    <input type='reset' value='submit 2 to b' onclick='which(this);'>
    <input type='hidden' name='whichButton'>
    </form>
    ===============

    Chrome on pc tested, not chrome-beta for Ice Cream Sandwich.


    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
     
    Evertjan., Feb 8, 2012
    #1
    1. Advertisements

  2. Evertjan.

    Ross McKay Guest

    On 08 Feb 2012 10:04:02 GMT, "Evertjan." wrote:

    >Misusing the reset-button into submission is fun
    >[...]


    Coming soon to The Daily WTF, no doubt... :(
    --
    Ross McKay, Toronto, NSW Australia
    "The chief cause of problems is solutions" -Eric Sevareid
     
    Ross McKay, Feb 8, 2012
    #2
    1. Advertisements

  3. 2012-02-08 12:10, Ross McKay wrote:

    > On 08 Feb 2012 10:04:02 GMT, "Evertjan." wrote:
    >
    >> Misusing the reset-button into submission is fun
    >> [...]

    >
    > Coming soon to The Daily WTF, no doubt... :(


    But what's the point of messings things up in a difficult way, when it
    can be done so easily? No reason to rely on JavaScript being enabled
    when you can confuse *everyone* (except source code peekers).

    <input type=submit name=Cancel>
    <input type=reset name=Submit>

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, Feb 8, 2012
    #3
  4. 2012-02-08 12:10, Ross McKay wrote:

    > On 08 Feb 2012 10:04:02 GMT, "Evertjan." wrote:
    >
    >> Misusing the reset-button into submission is fun
    >> [...]

    >
    > Coming soon to The Daily WTF, no doubt...


    But what's the point of messings things up in a difficult way, when it
    can be done so easily? No reason to rely on JavaScript being enabled
    when you can confuse *everyone* (except source code peekers).

    <input type=submit value=Cancel>
    <input type=reset value=Submit>

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, Feb 8, 2012
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Similar Threads
  1. Chris Lane
    Replies:
    4
    Views:
    11,770
    Chris Lane
    Nov 17, 2003
  2. angus

    a reset button

    angus, May 19, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    790
    Cliff Harris
    May 19, 2004
  3. John

    Reset button code

    John, Oct 8, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    5,890
    Lucas Tam
    Oct 8, 2004
  4. NancyASAP
    Replies:
    2
    Views:
    16,723
    parndt
    Oct 16, 2007
  5. Penny Bond
    Replies:
    3
    Views:
    1,288
    Trevor Benedict R
    Mar 16, 2005
  6. PC Leung
    Replies:
    1
    Views:
    569
    Murray
    Jul 9, 2004
  7. Reiner Wagner

    RESET button as an image

    Reiner Wagner, Jul 6, 2005, in forum: HTML
    Replies:
    3
    Views:
    13,382
    Vladdy
    Jul 6, 2005
  8. jtl.zheng
    Replies:
    10
    Views:
    1,012
    JTL.zheng
    Sep 2, 2006
Loading...