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., Feb 8, 2012
    #1
    1. Advertisements

  2. Evertjan.

    Ross McKay Guest

    Coming soon to The Daily WTF, no doubt... :(
     
    Ross McKay, Feb 8, 2012
    #2
    1. Advertisements

  3. 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>
     
    Jukka K. Korpela, Feb 8, 2012
    #3
  4. 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>
     
    Jukka K. Korpela, Feb 8, 2012
    #4
    1. Advertisements

Ask a Question

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.