473,396 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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_form" method="post" action="search.php">
.....
....
Code: <input type="text" name="code" onKeyPress="if (event.keyCode ==
13) {document.search_form.submit()};">

....
....

How can I do it without a submit button?

Many Thanks.
Bettina

Aug 5 '05 #1
8 6156
be*****@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_form" method="post" action="search.php">
....
...
Code: <input type="text" name="code" onKeyPress="if (event.keyCode ==
13) {document.search_form.submit()};">

...
...

How can I do it without a submit button?

Many Thanks.
Bettina


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

<form name='search_form' id='search_form' method='post'
action='search.php'>
<a href='#' onClick='document.myForm.submit();'>Click here</a>
</form>

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

Aug 5 '05 #2
Another way to do it would be like this:

<form name='search_form' id='search_form' method='post'
action='search.php'>
<a href='javascript: document.myForm.submit();'>Click here</a>
</form>

Aug 5 '05 #3
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:
Another way to do it would be like this:

<form name='search_form' id='search_form' method='post'
action='search.php'>
<a href='javascript: document.myForm.submit();'>Click here</a>
</form>


Aug 5 '05 #4

be*****@coaster.ch wrote:
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:
Another way to do it would be like this:

<form name='search_form' id='search_form' method='post'
action='search.php'>
<a href='javascript: document.myForm.submit();'>Click here</a>
</form>


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

Huh??

Aug 6 '05 #5
"bryanhales" <br********@gmail.com> kirjoitti
viestissä:11**********************@o13g2000cwo.goo glegroups.com...
be*****@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_form" method="post" action="search.php">
....
...
Code: <input type="text" name="code" onKeyPress="if (event.keyCode ==
13) {document.search_form.submit()};">

...
...

How can I do it without a submit button?

Many Thanks.
Bettina


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

<form name='search_form' id='search_form' method='post'
action='search.php'>
<a href='#' onClick='document.myForm.submit();'>Click here</a>
</form>

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

And prefarbly the code would call the correct form id.

<form name='search_form' id='search_form' method='post'
action='search.php'>
<a href='#' onClick='document.search_form.submit();'>Click 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.berkeley.edu/>

Soulman <et****************@5P4Mgmail.com>
Aug 6 '05 #6
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.

Aug 6 '05 #7
On 5 Aug 2005 15:10:01 -0700,
bryanhales<br********@gmail.com> wrote:
be*****@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_form" method="post" action="search.php">
....
...
Code: <input type="text" name="code" onKeyPress="if (event.keyCode ==
13) {document.search_form.submit()};">

Strange. A simple

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

tends to work for me. Even in IE.
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 think you have the right idea...
Here is how it could be done using a link:

<form name='search_form' id='search_form' method='post'
action='search.php'>
<a href='#' onClick='document.myForm.submit();'>Click here</a>
</form>


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

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
Aug 7 '05 #8
=?ISO-8859-1?Q?Nisse_Engstr=F6m?= (Pv***********@tele2.se) wrote:
: On 5 Aug 2005 15:10:01 -0700,
: bryanhales<br********@gmail.com> wrote:
: > be*****@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_form" method="post" action="search.php">
: > > ....
: > > ...
: > > Code: <input type="text" name="code" onKeyPress="if (event.keyCode ==
: > > 13) {document.search_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.
Aug 7 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Matt | last post by:
Can form.submit() submit another form? In the following example, in page1.asp, it is fine to submit the current form: form1.submit(), and and I could see the value "Joe" in page2.asp. However, if I...
2
by: Terence Parker | last post by:
How does one go about submitting a form with a link - but submitting it to a new window AND to a page different to that described within the action="" option of the <form> tag? Say, for example,...
4
by: Sarah | last post by:
Hi all. I have a form, and several text and image links on it that should submit the form with different actions. I prepared a simple page with just the code that's not working. PROBLEM:...
15
by: M Smith | last post by:
I have a form I want to submit to itself. I want to be able to type in a list of numbers and submit the form and have that list show up on the same form under the text box I typed them into and...
6
by: CJM | last post by:
Can somebody clarify if/how/when a simple form is submitted when the <Enter> key is pressed? As I understood it, if you have a form with a single submit button, if enter is pressed, the form...
8
by: horos | last post by:
hey all, Ok, a related question to my previous one on data dumpers for postscript. In the process of putting a form together, I'm using a lot of placeholder variables that I really don't care...
5
by: rjames.clarke | last post by:
I have the following. $result=mysql_query($sql); $nrows=mysql_num_rows($result); for ($i=0;$i<$nrows;$i++) { $row_array=mysql_fetch_row($result); echo "<form name='testform'...
5
by: Navillus | last post by:
Hey gang, I have a login form that is empty by default, but can be filled with values from a previous form: <input type=text maxlength="40" size="40" name="user" value="`usr`"> <input...
10
by: ljlolel | last post by:
So.. I have a form that submits to an ASP.net site made in C-sharp. The ASP site is not mine, i do not have the server side code. When I submit from my form by pressing the Submit button, I get...
1
by: gbezas | last post by:
Hi All, I have added an event handler to redirect form.submit() to a newSubmit() method that I have defined (which does some additional processing before submitting the form). Additionally I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.