Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > How do I stop link a Text input to a Submit button?

Reply
Thread Tools

How do I stop link a Text input to a Submit button?

 
 
Robert S
Guest
Posts: n/a
 
      07-12-2006
I have a rather large page with an arbitrary number of "submit"
buttons. When a user enters something in a Text field and presses the
"Enter" key, the wrong action occurs (usually the "Delete" key gets
pressed!).

I am unable to subdivide the page into multiple Forms because all of
the data in the text fields needs to be updated when any of the Submit
buttons gets clicked.

How can I link a Submit button to a specific Text input?

 
Reply With Quote
 
 
 
 
aaron.reese@tiscali.co.uk
Guest
Posts: n/a
 
      07-12-2006

Robert S wrote:

> I am unable to subdivide the page into multiple Forms because all of
> the data in the text fields needs to be updated when any of the Submit
> buttons gets clicked.



Why does that stop it from being in multiple forms. I am assuming you
are using PHP or PERL to subit the field values either to another
function or to an SQL update/insert string. If all the fields need to
be validated/updated then why not just have one submit button. If only
the field associated with the submit button needs to be
updated/inserted, then each field should be in a separate form. If you
want to do it client-side rather than server side, you could set the
on_click event of each submit button to run a javascript function to
carry out the validation. This function could take an argument which
would be the submit button clicked on.

If I've missed the point, then please repost with an example of your
problem

 
Reply With Quote
 
 
 
 
Jukka K. Korpela
Guest
Posts: n/a
 
      07-12-2006
Robert S <> scripsit:

> I have a rather large page with an arbitrary number of "submit"
> buttons. When a user enters something in a Text field and presses the
> "Enter" key, the wrong action occurs (usually the "Delete" key gets
> pressed!).


This is a special case (and apparently a particularly nasty case) of the
problem "how do I prevent a form from being submitted when the user hits
Enter?". The answer is, more or less, "You don't; cope with it when it
happens".

See http://ppewww.ph.gla.ac.uk/~flavell/...mquestion.html

The safe, though sometimes a bit clumsy, approach is that you don't have
several submit buttons (when the form contains at least one text input
field).

This means that you don't have, say, "Delete", "Add" and "Change" submit
buttons. Instead, you have e.g. radio buttons for selecting the action to be
made, with such values, and a single submit button.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

 
Reply With Quote
 
Robert S
Guest
Posts: n/a
 
      07-13-2006
Jukka K. Korpela wrote:
> Robert S <> scripsit:
>
> > I have a rather large page with an arbitrary number of "submit"
> > buttons. When a user enters something in a Text field and presses the
> > "Enter" key, the wrong action occurs (usually the "Delete" key gets
> > pressed!).

>
> The safe, though sometimes a bit clumsy, approach is that you don't have
> several submit buttons (when the form contains at least one text input
> field).
>


I think you have the hang of the problem. There are a lot of <input>
controls on the page and they all need to be submitted when any of the
"submit" buttons are pressed. The first "submit" button on the page is
the one that gets "pressed" when a user presses "Enter". I might try
creating a hidden button that refreshes the page when a user presses
Enter. That will prevent any damage from occurring. Anyone like to
tell me how to create a hidden "submit" button?

 
Reply With Quote
 
Alan J. Flavell
Guest
Posts: n/a
 
      07-13-2006
On Thu, 13 Jul 2006, Jukka K. Korpela wrote:

> Robert S <> scripsit:
>
> > I have a rather large page with an arbitrary number of "submit"
> > buttons. When a user enters something in a Text field and presses
> > the "Enter" key, the wrong action occurs (usually the "Delete" key
> > gets pressed!).


Is the "Delete" key your first submit button?

> This is a special case (and apparently a particularly nasty case) of
> the problem "how do I prevent a form from being submitted when the
> user hits Enter?". The answer is, more or less, "You don't; cope
> with it when it happens".


I'll go along with that...

> See http://ppewww.ph.gla.ac.uk/~flavell/...mquestion.html


thanks...

> The safe, though sometimes a bit clumsy, approach is that you don't
> have several submit buttons (when the form contains at least one
> text input field).


Right. However, to the best of my recollection (see my web page for
details, though), *if* the form is submitted in this way, *and* the
focus is not on one of the submit controls, then one of the following
happens:

1 - No name=value attribute corresponding to a submit control is sent

2 - The name=value attribute corresponding to the *first* submit
control is sent.

The first case should be easy to deal with.

The second one can be handled by making the first submit control
be something harmless, such as "Preview".

> This means that you don't have, say, "Delete", "Add" and "Change"
> submit buttons. Instead, you have e.g. radio buttons for selecting
> the action to be made, with such values, and a single submit button.


It's a reasonable option, indeed. But the other approach can be
slightly more convenient for the user, and I don't recall any browser
on which it causes problems.

cheers

(Excuse the pedantry with referring to "submit controls", but I'm
always worried about possible confusion with <input type=button> and
<button> when one's talking about "buttons".)
 
Reply With Quote
 
Steven Saunderson
Guest
Posts: n/a
 
      07-13-2006
On 13 Jul 2006 03:48:14 -0700, "Robert S"
<> wrote:

> I think you have the hang of the problem. There are a lot of <input>
> controls on the page and they all need to be submitted when any of the
> "submit" buttons are pressed. The first "submit" button on the page is
> the one that gets "pressed" when a user presses "Enter". I might try
> creating a hidden button that refreshes the page when a user presses
> Enter. That will prevent any damage from occurring. Anyone like to
> tell me how to create a hidden "submit" button?


I put a dummy button after the text boxes :

<input type="submit" name="none" value="" style="visibility:hidden">

HTH

--
Steven
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Re: Make submit look like a text link Els HTML 9 01-08-2009 11:22 AM
Submit form with text-link Martin Schneider HTML 1 02-07-2004 05:25 PM
why does form with only 1 text input and 1 button input submit on enter? Guy HTML 5 12-13-2003 06:44 AM
input=text fires Submit when pressing Enter Jerry ASP .Net 4 07-25-2003 01:38 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57