Submit Form

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • bettina@coaster.ch

    #1

    Submit Form

    I want to submit a form but without a submit button. That's to say, I
    want that by giving a definite code in a field and then press <ENTER>
    the form will be submitted.
    For Example
    <form name="search_fo rm" method="post" action="search. php">
    .....
    ....
    Code: <input type="text" name="code" onKeyPress="if (event.keyCode ==
    13) {document.searc h_form.submit() };">

    ....
    ....

    How can I do it without a submit button?

    Many Thanks.
    Bettina

  • bryanhales

    #2
    Re: Submit Form

    bettina@coaster .ch wrote:[color=blue]
    > I want to submit a form but without a submit button. That's to say, I
    > want that by giving a definite code in a field and then press <ENTER>
    > the form will be submitted.
    > For Example
    > <form name="search_fo rm" method="post" action="search. php">
    > ....
    > ...
    > Code: <input type="text" name="code" onKeyPress="if (event.keyCode ==
    > 13) {document.searc h_form.submit() };">
    >
    > ...
    > ...
    >
    > How can I do it without a submit button?
    >
    > Many Thanks.
    > Bettina[/color]

    I think you have the right idea...
    Here is how it could be done using a link:

    <form name='search_fo rm' id='search_form ' method='post'
    action='search. php'>
    <a href='#' onClick='docume nt.myForm.submi t();'>Click here</a>
    </form>

    The key, I believe, is to have the "id" in the form tag.

    Comment

    • bryanhales

      #3
      Re: Submit Form

      Another way to do it would be like this:

      <form name='search_fo rm' id='search_form ' method='post'
      action='search. php'>
      <a href='javascrip t: document.myForm .submit();'>Cli ck here</a>
      </form>

      Comment

      • bettina@coaster.ch

        #4
        Re: Submit Form

        I tried both and I've got a Fehler auf die Seite... I think I will try
        to format the button so that it looks like text!

        bryanhales schrieb:
        [color=blue]
        > Another way to do it would be like this:
        >
        > <form name='search_fo rm' id='search_form ' method='post'
        > action='search. php'>
        > <a href='javascrip t: document.myForm .submit();'>Cli ck here</a>
        > </form>[/color]

        Comment

        • bryanhales

          #5
          Re: Submit Form


          bettina@coaster .ch wrote:[color=blue]
          > I tried both and I've got a Fehler auf die Seite... I think I will try
          > to format the button so that it looks like text!
          >
          > bryanhales schrieb:
          >[color=green]
          > > Another way to do it would be like this:
          > >
          > > <form name='search_fo rm' id='search_form ' method='post'
          > > action='search. php'>
          > > <a href='javascrip t: document.myForm .submit();'>Cli ck here</a>
          > > </form>[/color][/color]

          "I tried both and I've got a Fehler auf die Seite..."

          Huh??

          Comment

          • Kimmo Laine

            #6
            Re: Submit Form

            "bryanhales " <bryanhales@gma il.com> kirjoitti
            viestissä:11232 79801.255151.15 5030@o13g2000cw o.googlegroups. com...[color=blue]
            > bettina@coaster .ch wrote:[color=green]
            >> I want to submit a form but without a submit button. That's to say, I
            >> want that by giving a definite code in a field and then press <ENTER>
            >> the form will be submitted.
            >> For Example
            >> <form name="search_fo rm" method="post" action="search. php">
            >> ....
            >> ...
            >> Code: <input type="text" name="code" onKeyPress="if (event.keyCode ==
            >> 13) {document.searc h_form.submit() };">
            >>
            >> ...
            >> ...
            >>
            >> How can I do it without a submit button?
            >>
            >> Many Thanks.
            >> Bettina[/color]
            >
            > I think you have the right idea...
            > Here is how it could be done using a link:
            >
            > <form name='search_fo rm' id='search_form ' method='post'
            > action='search. php'>
            > <a href='#' onClick='docume nt.myForm.submi t();'>Click here</a>
            > </form>
            >
            > The key, I believe, is to have the "id" in the form tag.[/color]


            And prefarbly the code would call the correct form id.

            <form name='search_fo rm' id='search_form ' method='post'
            action='search. php'>
            <a href='#' onClick='docume nt.search_form. submit();'>Clic k here</a>
            </form>

            Your a href called myForm, but the form was called search_form. I'm not
            surprised bettina got an "error on page" notification

            --
            SETI @ Home - Donate your cpu's idle time to science.
            Further reading at <http://setiweb.ssl.ber keley.edu/>

            Soulman <eternal.erecti onN0@5P4Mgmail. com>


            Comment

            • bettina@coaster.ch

              #7
              Re: Submit Form

              No Kimmo, it's not a question of the id name. I had already realized
              that "myform" should be wrong and I tried with the correct form id but
              it doesn't work either.

              Comment

              • Nisse Engström

                #8
                Re: Submit Form

                On 5 Aug 2005 15:10:01 -0700,
                bryanhales<brya nhales@gmail.co m> wrote:[color=blue]
                > bettina@coaster .ch wrote:[color=green]
                > > I want to submit a form but without a submit button. That's to say, I
                > > want that by giving a definite code in a field and then press <ENTER>
                > > the form will be submitted.
                > > For Example
                > > <form name="search_fo rm" method="post" action="search. php">
                > > ....
                > > ...
                > > Code: <input type="text" name="code" onKeyPress="if (event.keyCode ==
                > > 13) {document.searc h_form.submit() };">
                > >[/color][/color]

                Strange. A simple

                <input type="text" name="code">

                tends to work for me. Even in IE.
                [color=blue][color=green]
                > > How can I do it without a submit button?[/color][/color]

                Beware, there is no shortage of pages with broken Javascripts
                where forms cannot be submitted *at all*. Not having a submit
                button is *extremely* rude in those cases.
                [color=blue]
                > I think you have the right idea...
                > Here is how it could be done using a link:
                >
                > <form name='search_fo rm' id='search_form ' method='post'
                > action='search. php'>
                > <a href='#' onClick='docume nt.myForm.submi t();'>Click here</a>
                > </form>[/color]

                [Note: "myForm" above should've been "search_for m".]

                This is major nuisance. Not only because the link takes the user
                to the current page instead of submitting the form, if Javascript
                is not available. But also because it uses DOM manipulation that
                is specific to IE (and "bug"-compatible browsers), which might
                render the link *entirely* useless.

                Don't try to duplicate functionality that already exists in every
                browser on the planet. Use a submit button the way it was intended.
                Use links with real urls the way they were intended. This horse
                has already been beaten to death many times in various newsgroups.


                --n

                Comment

                • Malcolm Dew-Jones

                  #9
                  Re: Submit Form

                  =?ISO-8859-1?Q?Nisse_Engst r=F6m?= (PvovotkNOSPAM@ tele2.se) wrote:
                  : On 5 Aug 2005 15:10:01 -0700,
                  : bryanhales<brya nhales@gmail.co m> wrote:
                  : > bettina@coaster .ch wrote:
                  : > > I want to submit a form but without a submit button. That's to say, I
                  : > > want that by giving a definite code in a field and then press <ENTER>
                  : > > the form will be submitted.
                  : > > For Example
                  : > > <form name="search_fo rm" method="post" action="search. php">
                  : > > ....
                  : > > ...
                  : > > Code: <input type="text" name="code" onKeyPress="if (event.keyCode ==
                  : > > 13) {document.searc h_form.submit() };">
                  : > >

                  : Strange. A simple

                  : <input type="text" name="code">

                  : tends to work for me. Even in IE.

                  It doesn't work in all browsers. In some browsers you have to have a
                  submit button.

                  : > > How can I do it without a submit button?

                  : Beware, there is no shortage of pages with broken Javascripts
                  : where forms cannot be submitted *at all*. Not having a submit
                  : button is *extremely* rude in those cases.

                  I agree, a form should always have a submit button if you intend it to be
                  submitted. A plain submit button (i.e. no javascript) will work in 100%
                  of browsers, and makes it plain to every user how to submit. Having a
                  submit button does not prevent the user from simply pressing the Enter key
                  to submit the form in those browsers that do that, so nothing is lost by
                  having a button.


                  --

                  This space not for rent.

                  Comment

                  Working...