Form with 2 buttons

Discussion in 'HTML' started by shapper, Feb 17, 2009.

  1. shapper

    shapper Guest

    Hello,

    I have a form as follows (Just a smaller example what I have):

    <form id="Edit" method="post" action="/Account/Edit">
    <fieldset>
    <label for="Name">Name</label>
    <input id="Name" type="text" value="" name="Name"/>
    </fieldset>
    <fieldset>
    <input id="Submit" type="submit" value="Save" title="Save"
    name="Save"/>
    </fieldset>
    </form>

    Can a form have two submit buttons?

    Basically, I would like to go to /Account/Edit if Save is pressed or
    some other action if another button on the form is pressed.

    Thanks,
    Miguel
     
    shapper, Feb 17, 2009
    #1
    1. Advertising

  2. shapper wrote:
    > Hello,
    >
    > I have a form as follows (Just a smaller example what I have):
    >
    > <form id="Edit" method="post" action="/Account/Edit">
    > <fieldset>
    > <label for="Name">Name</label>
    > <input id="Name" type="text" value="" name="Name"/>
    > </fieldset>
    > <fieldset>
    > <input id="Submit" type="submit" value="Save" title="Save"
    > name="Save"/>
    > </fieldset>
    > </form>
    >
    > Can a form have two submit buttons?
    >
    > Basically, I would like to go to /Account/Edit if Save is pressed or
    > some other action if another button on the form is pressed.


    You cannot change the action of a form with a second submit button using
    HTML, it would require AND depend on JavaScript which would be a "bad
    idea". You can have a second submit button with a different *value* and
    or different *name* then test with the receiving server-side script for
    the said value or name and process accordingly.

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
     
    Jonathan N. Little, Feb 17, 2009
    #2
    1. Advertising

  3. shapper wrote:

    > Can a form have two submit buttons?


    Yes. This used to be a frequently asked question, which was answered in FAQ
    lists. You need to have different name="..." attributes, or different
    value="..." attributes, or both, if you want to associate different
    operations with different buttons. Naturally, your server-side form data
    handler must then do the branching.

    But that's really not all...

    > Basically, I would like to go to /Account/Edit if Save is pressed or
    > some other action if another button on the form is pressed.


    The tough problem is what happens when a user hits the Enter key in a text
    input box. This usually submits the form. Which operation will then take
    place? This problem is described at
    http://www.alanflavell.org.uk/www/formquestion.html
    but the short answer is really that it is safest to use radio buttons (or a
    select element) for selecting the operation. In that case, you can use just
    one submit button.

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, Feb 17, 2009
    #3
  4. On Tue, 17 Feb 2009 23:34:55 +0200, "Jukka K. Korpela"
    <> wrote:

    >shapper wrote:
    >
    >> Can a form have two submit buttons?

    >
    >Yes. This used to be a frequently asked question, which was answered in FAQ
    >lists. You need to have different name="..." attributes, or different
    >value="..." attributes, or both, if you want to associate different
    >operations with different buttons. Naturally, your server-side form data
    >handler must then do the branching.
    >
    >But that's really not all...
    >
    >> Basically, I would like to go to /Account/Edit if Save is pressed or
    >> some other action if another button on the form is pressed.

    >
    >The tough problem is what happens when a user hits the Enter key in a text
    >input box. This usually submits the form. Which operation will then take
    >place? This problem is described at
    >http://www.alanflavell.org.uk/www/formquestion.html
    >but the short answer is really that it is safest to use radio buttons (or a
    >select element) for selecting the operation. In that case, you can use just
    >one submit button.


    Correct - but not all forms do a submit when you hit "Enter" in a text
    box.
    Another thing to think about ...is, if you have 2 butttons on a form,
    be sure that clicking on one of those prohibit the click, on the
    other.
     
    Raymond Schmit, Feb 19, 2009
    #4
  5. shapper

    Mel Smith Guest

    "Jukka K. Korpela" <> wrote in message
    news:a4Gml.3303$...
    > The tough problem is what happens when a user hits the Enter key in a text
    > input box. This usually submits the form. Which operation will then take
    > place? This problem is described at
    > http://www.alanflavell.org.uk/www/formquestion.html
    > but the short answer is really that it is safest to use radio buttons (or
    > a select element) for selecting the operation. In that case, you can use
    > just one submit button.


    Jukka:

    I read over thoroughly the above article and how your suggestions were
    cited.

    I wonder if your ideas (of a 'preview' button, and then a final 'submit'
    button) have changed since the time you suggested this method (which seems
    like a good idea).

    My Problem: I would like to have a 'correspondent' use a text area to
    post lengthy bulletins, messages, articles, to my website (with the
    accompanying high speed blur of <enter> keys which signify to her ends of
    paragraphs).

    This 'author' of our club monthly bulletin is used to older fashioned
    word processsors, but I want to have her do one of two things:

    a. Use the Open Office Swriter program and send me 'articles' that I
    would then open/convert to html code (using OO html saving methods) and
    create a page on my site for other viewers, or,

    b. Have her directly enter her articles on a textarea page on my
    site -- which *then* get into the <enter> key problems mentioned in
    Flavell's notes and your solution.

    Have you any further thoughts on this ??

    TIA,

    -Mel Smith
     
    Mel Smith, Feb 19, 2009
    #5
  6. Mel Smith wrote:

    > My Problem: I would like to have a 'correspondent' use a text
    > area to post lengthy bulletins, messages, articles, to my website
    > (with the accompanying high speed blur of <enter> keys which signify
    > to her ends of paragraphs).


    I don't see a technical problem here, since Enter does not trigger form
    submission when you're in a textarea field. Well, there's the problem of
    awkward input, and you should really instruct people into using their
    favorite text editor and then do copy & paste, instead of directly typing a
    lot of text in a textarea. Two major reasons:
    a) any text editor, even Notepad, is superior to browsers' implementation of
    textarea
    b) in particular, the user can (and should) save their input locally.

    Remember the old joke about Jesus and Devil in a coding competition? They
    coded and typed and hacked for almost an hour (the competition was limited
    to one hour), then there was a short power off situation. The Devil was
    desperate, having lost all his input, but Jesus completed the task easily
    and shouted "Jesus saves!"

    When processing textarea input data, you need to be careful enough to
    recognize empty lines (consecutive ends of line), if you need to treat them
    as paragraph separators.

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, Feb 19, 2009
    #6
  7. shapper

    dorayme Guest

    In article <3oinl.4036$>,
    "Jukka K. Korpela" <> wrote:

    > Mel Smith wrote:
    >
    > > My Problem: I would like to have a 'correspondent' use a text
    > > area to post lengthy bulletins, messages, articles, to my website
    > > (with the accompanying high speed blur of <enter> keys which signify
    > > to her ends of paragraphs).

    >

    ....
    > b) in particular, the user can (and should) save their input locally.
    >

    ....

    The most annoying thing I have found about many text areas is the
    miserable amount of space allotted before having to scroll. So,
    providing a nice big area is perhaps another thing to watch for.

    On Macs one can just drag all the text so far to the desktop and save as
    a clipping and throw away later, not sure what is the quickest way to
    temporarily save on windows?

    --
    dorayme
     
    dorayme, Feb 19, 2009
    #7
  8. shapper

    Mel Smith Guest

    "Jukka K. Korpela" <> wrote in message
    news:3oinl.4036$...
    > I don't see a technical problem here, since Enter does not trigger form
    > submission when you're in a textarea field. Well, there's the problem of
    > awkward input, and you should really instruct people into using their
    > favorite text editor and then do copy & paste, instead of directly typing
    > a lot of text in a textarea. Two major reasons:
    > a) any text editor, even Notepad, is superior to browsers' implementation
    > of textarea


    Yes, Notepad would be a good solution for her (along with Copy/Paste

    > b) in particular, the user can (and should) save their input locally.
    >
    > Remember the old joke about Jesus and Devil in a coding competition? They
    > coded and typed and hacked for almost an hour (the competition was limited
    > to one hour), then there was a short power off situation. The Devil was
    > desperate, having lost all his input, but Jesus completed the task easily
    > and shouted "Jesus saves!"


    :))

    > When processing textarea input data, you need to be careful enough to
    > recognize empty lines (consecutive ends of line), if you need to treat
    > them as paragraph separators.


    Yes, I'll do that !

    Thanks for the tips (especially jogging my memory about Copy/Paste !)

    -Mel Smith
     
    Mel Smith, Feb 20, 2009
    #8
  9. shapper

    Mel Smith Guest

    "dorayme" <> wrote in message
    news:...
    > The most annoying thing I have found about many text areas is the
    > miserable amount of space allotted before having to scroll. So,
    > providing a nice big area is perhaps another thing to watch for.
    >


    Yes, I'll make the basic area big and scollable. I also assume that most
    of my clients will have Windows machines -- being conservative and *not*
    young.


    Thanks for the reminder about a larger text area.

    -Mel Smith
     
    Mel Smith, Feb 20, 2009
    #9
  10. shapper

    dorayme Guest

    In article <>,
    "Mel Smith" <> wrote:

    > "dorayme" <> wrote in message
    > news:...
    > > The most annoying thing I have found about many text areas is the
    > > miserable amount of space allotted before having to scroll. So,
    > > providing a nice big area is perhaps another thing to watch for.
    > >

    >
    > Yes, I'll make the basic area big and scollable. I also assume that most
    > of my clients will have Windows machines -- being conservative and *not*
    > young.
    >
    >

    You would be surprised at how many older folk have Macs! But they are a
    small percentage of almost all markets, true!

    > Thanks for the reminder about a larger text area.
    >
    > -Mel Smith


    --
    dorayme
     
    dorayme, Feb 20, 2009
    #10
  11. On 2009-02-19, dorayme wrote:
    > In article <3oinl.4036$>,
    > "Jukka K. Korpela" <> wrote:
    >
    >> Mel Smith wrote:
    >>
    >> > My Problem: I would like to have a 'correspondent' use a text
    >> > area to post lengthy bulletins, messages, articles, to my website
    >> > (with the accompanying high speed blur of <enter> keys which signify
    >> > to her ends of paragraphs).

    >>

    > ...
    >> b) in particular, the user can (and should) save their input locally.
    >>

    > ...
    >
    > The most annoying thing I have found about many text areas is the
    > miserable amount of space allotted before having to scroll. So,
    > providing a nice big area is perhaps another thing to watch for.
    >
    > On Macs one can just drag all the text so far to the desktop and save as
    > a clipping and throw away later, not sure what is the quickest way to
    > temporarily save on windows?


    There is a Firefox add-on, It's All Text, which allows you to call
    up the text editor of your choice when in a text area.


    --
    Chris F.A. Johnson, webmaster <http://Woodbine-Gerrard.com>
    ===================================================================
    Author:
    Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
     
    Chris F.A. Johnson, Feb 20, 2009
    #11
  12. shapper

    dorayme Guest

    In article <d4b4b$499e1aee$cef88ba3$>,
    "Chris F.A. Johnson" <> wrote:

    > On 2009-02-19, dorayme wrote:
    > > In article <3oinl.4036$>,
    > > "Jukka K. Korpela" <> wrote:
    > >
    > >> Mel Smith wrote:
    > >>
    > >> > My Problem: I would like to have a 'correspondent' use a text
    > >> > area to post lengthy bulletins, messages, articles, to my website
    > >> > (with the accompanying high speed blur of <enter> keys which signify
    > >> > to her ends of paragraphs).
    > >>

    > > ...
    > >> b) in particular, the user can (and should) save their input locally.
    > >>

    > > ...
    > >
    > > The most annoying thing I have found about many text areas is the
    > > miserable amount of space allotted before having to scroll. So,
    > > providing a nice big area is perhaps another thing to watch for.
    > >
    > > On Macs one can just drag all the text so far to the desktop and save as
    > > a clipping and throw away later, not sure what is the quickest way to
    > > temporarily save on windows?

    >
    > There is a Firefox add-on, It's All Text, which allows you to call
    > up the text editor of your choice when in a text area.


    I will get it! What a beaut idea.

    --
    dorayme
     
    dorayme, Feb 20, 2009
    #12
  13. shapper

    dorayme Guest

    In article <>,
    dorayme <> wrote:

    > In article <d4b4b$499e1aee$cef88ba3$>,
    > "Chris F.A. Johnson" <> wrote:
    >
    > > On 2009-02-19, dorayme wrote:


    > > There is a Firefox add-on, It's All Text, which allows you to call
    > > up the text editor of your choice when in a text area.

    >
    > I will get it! What a beaut idea.


    I got it and it is good, thanks for that. Now I can *really* tell my
    bank what is bad with their website on their feedback page!

    --
    dorayme
     
    dorayme, Feb 20, 2009
    #13
  14. shapper

    Mel Smith Guest

    "dorayme" <> wrote in message
    news:...
    > I got it and it is good, thanks for that. Now I can *really* tell my
    > bank what is bad with their website on their feedback page!



    Dorayme:

    I looked for it thru all the 'extras' and 'Tools' and Add-ons, but
    couldn't find it :((

    Maybe an additional pointer to the 'clueless' ?

    (I *do* have Firefox on my machine for testing, not just IE7 and IE8 )

    -Mel Smith
     
    Mel Smith, Feb 21, 2009
    #14
  15. shapper

    Mel Smith Guest

    "Mel Smith" <> wrote in message
    news:...

    > Dorayme:
    > > I looked for it thru all the 'extras' and 'Tools' and Add-ons, but

    > couldn't find it :((
    >
    > Maybe an additional pointer to the 'clueless' ?



    Dorayme:

    Please ignore my request, I found it !

    -Mel Smith
     
    Mel Smith, Feb 21, 2009
    #15
  16. shapper

    dorayme Guest

    In article <>,
    "Mel Smith" <> wrote:

    > "dorayme" <> wrote in message
    > news:...
    > > I got it and it is good, thanks for that. Now I can *really* tell my
    > > bank what is bad with their website on their feedback page!

    >
    >
    > dorayme:
    >
    > I looked for it thru all the 'extras' and 'Tools' and Add-ons, but
    > couldn't find it :((
    >
    > Maybe an additional pointer to the 'clueless' ?
    >
    > (I *do* have Firefox on my machine for testing, not just IE7 and IE8 )
    >
    >


    Open up FF and stick this in and say yes to everything

    https://addons.mozilla.org/en-US/firefox/addon/4125

    --
    dorayme
     
    dorayme, Feb 21, 2009
    #16
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roger
    Replies:
    1
    Views:
    640
    GreggTB
    May 20, 2005
  2. =?Utf-8?B?QmVu?=

    Image Buttons/Buttons not responding

    =?Utf-8?B?QmVu?=, Jul 6, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    451
    Teemu Keiski
    Jul 6, 2005
  3. Jeremy Jones

    Datagrid Nav buttons and numeric buttons

    Jeremy Jones, Mar 21, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    627
    Masudur
    Mar 22, 2007
  4. Jonathan N. Little
    Replies:
    3
    Views:
    526
    Andy Dingley
    Apr 2, 2007
  5. Dr. Leff
    Replies:
    3
    Views:
    299
    David Mark
    Oct 15, 2007
Loading...

Share This Page