Form with 2 buttons

S

shapper

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
 
J

Jonathan N. Little

shapper said:
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.
 
J

Jukka K. Korpela

shapper said:
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.
 
R

Raymond Schmit

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...


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.
 
M

Mel Smith

Jukka K. Korpela said:
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
 
J

Jukka K. Korpela

Mel said:
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.
 
D

dorayme

"Jukka K. Korpela said:
....
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?
 
M

Mel Smith

Jukka K. Korpela said:
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
 
M

Mel Smith

dorayme said:
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
 
D

dorayme

"Mel Smith said:
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!
 
C

Chris F.A. Johnson

...

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.
 
D

dorayme

"Chris F.A. Johnson said:
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.
 
D

dorayme

dorayme said:
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!
 
M

Mel Smith

dorayme said:
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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top