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

Discussion in 'HTML' started by Robert S, Jul 12, 2006.

  1. Robert S

    Robert S Guest

    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?
     
    Robert S, Jul 12, 2006
    #1
    1. Advertising

  2. Robert S

    Guest

    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
     
    , Jul 12, 2006
    #2
    1. Advertising

  3. 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/www/formquestion.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/
     
    Jukka K. Korpela, Jul 12, 2006
    #3
  4. Robert S

    Robert S Guest

    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?
     
    Robert S, Jul 13, 2006
    #4
  5. 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/www/formquestion.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".)
     
    Alan J. Flavell, Jul 13, 2006
    #5
  6. 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
     
    Steven Saunderson, Jul 13, 2006
    #6
    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. Mark
    Replies:
    1
    Views:
    1,799
  2. Ghafran Abbas
    Replies:
    0
    Views:
    4,316
    Ghafran Abbas
    Oct 12, 2004
  3. Guy
    Replies:
    5
    Views:
    2,877
    brucie
    Dec 13, 2003
  4. Replies:
    2
    Views:
    6,376
  5. Network-Man
    Replies:
    5
    Views:
    79,484
    gaul1
    Jul 7, 2012
Loading...

Share This Page