473,799 Members | 3,290 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ENTER key clearing form

I feel like a fool for asking this; seems like I would have had more
luck with Google, but alas...

This is a little baby bit of code that a friend cooked up over a year
ago. My problem is simply that hitting enter doesn't really submit
the input. It just reloads with a cleared form. My desired effect is
for hitting the Enter key to have the same effect as clicking the
Submit button.

Here's the code:

<!-- saved from url=(0013)about :internet -->
<script language = "javascript ">

function opensite()
{
location = "http://www.state.ar.us/dfa/personnel_mgmt/
classcodes/"+entry.num1.va lue+".txt";
}

</script>
<center>
<h2 align = "center">En ter the Class Code and click Submit</h2>

<form id = "entry">
<table>
<tr>
<td>
<input type = "text" id = "num1"></input>
</td>
</tr>
<tr>
<td align = "right">
<input type = "button" id = "submit" onclick = "opensite() " value =
"Submit"></input>
</td>
</tr>
</table>
</form>
</center>
<h3 align = "center"><f ont color = "Navy">You will find the MQs at the
bottom of the page.</font></h2>

I tried to make heads or tails of this post
:
http://groups.google.com/group/comp..../browse_thread
/thread/39d8b289a95afe7 9/10c205b5f6d17a0 f?lnk=st&q=
javascript+ente r+key#10c205b5f 6d17a0f

but I couldn't get it working.

(and, yes, I know GoogleGroups is the devil, but I can't get a real
newsreader at work)
Dec 17 '07 #1
3 1696
Eric D. Braden said the following on 12/17/2007 10:28 AM:
I feel like a fool for asking this; seems like I would have had more
luck with Google, but alas...

This is a little baby bit of code that a friend cooked up over a year
ago. My problem is simply that hitting enter doesn't really submit
the input. It just reloads with a cleared form. My desired effect is
for hitting the Enter key to have the same effect as clicking the
Submit button.
<URL:
http://groups.google.c om/group/comp.lang.javas cript/browse_thread/thread/a0407c1a089957f 7/5e55858025df711 5?lnk=gst&q=det ect+enter+key#5 e55858025df7115 >

<form onsubmit="opens ite();return false">

And then change your button to a submit button.
<input type = "button" id = "submit" onclick = "opensite() " value =
"Submit"></input>
<input type="submit" value="Submit">

Then, when the form gets submitted it will execute the opensite()
function and cancel submission of the form.
(and, yes, I know GoogleGroups is the devil, but I can't get a real
newsreader at work)
Google Groups isn't the devil. People using Google Groups without
realizing what it's going to screw up is the devil.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Dec 17 '07 #2
On Dec 17, 12:02 pm, Randy Webb <HikksNotAtH... @aol.comwrote:
Eric D. Braden said the following on 12/17/2007 10:28 AM:
I feel like a fool for asking this; seems like I would have had more
luck with Google, but alas...
snip helpful stuff
--
Randy
Chance Favors The Prepared Mind
comp.lang.javas cript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptT oolbox.com/bestpractices/
Thanks so much for your help! I had to hit myself on the head a few
times to get the <form onsubmitbit to work, but everything's daisies
now.
Dec 17 '07 #3
On Dec 18, 1:28 am, "Eric D. Braden" <bradener...@ho tmail.comwrote:
I feel like a fool for asking this; seems like I would have had more
luck with Google, but alas...

This is a little baby bit of code that a friend cooked up over a year
ago. My problem is simply that hitting enter doesn't really submit
the input. It just reloads with a cleared form. My desired effect is
for hitting the Enter key to have the same effect as clicking the
Submit button.
Irrelivant to your issue, which Randy has answered, but anyhow...
>
Here's the code:

<!-- saved from url=(0013)about :internet -->
<script language = "javascript ">
The language attribute is deprecated, type is required:

<script type="text/javascript">

<URL: http://www.w3.org/TR/html4/interact/...#adef-language >

[...]
<center>
The center element is deprecated, use CSS styling instead.

<URL: http://www.w3.org/TR/html4/present/g...ml#edef-CENTER >

[...]
<input type = "button" id = "submit" onclick = "opensite() " value =
"Submit"></input>
Closing tags for input elemens are forbidden.

<URL: http://www.w3.org/TR/html4/interact/...tml#edef-INPUT >
There are other issues with your markup, use a validator. The W3C
HTML validator is pretty good:

<URL: http://validator.w3.org/ >

--
Rob

Dec 18 '07 #4

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

Similar topics

2
2889
by: Robin | last post by:
Ok, I have a form that on clicking of the Update button first updates the specific record in the db, then Inserts if the vMemo field is not empty. The problem that I'm having is that After updating if you hit the key (refresh) it inserts another record ... I have tried: 1. Clearing the vMemo field after the insert is done (vMemo = "") 2. Setting the value on the form for this field to "" Neither of these are working. It's not...
2
1872
by: Savvas | last post by:
Hi everybody, I have a lot of textboxes on my form and a "Clear" button. Is there a way with a for loop or something to clear the textboxes, instead of writing textboxName.clear? Thanks a lot
3
7704
by: Darin | last post by:
I have a problem I just can't figure out. I have a form with a subform, and the recordsource of the subform has criteria based on some unbound fields in the parent form so that data in the parent form affects data in the subform. I've had this type of setup often, but I've run across a couple forms where this has caused an "enter parameter value" pop up for each reference to the parent control in the query when the main form is closed. ...
24
8447
by: MichaelK | last post by:
Who knows how to prevent submitting a form on the press Enter button before all fields on the form are filled up. People just enter the first field hit Enter and it submits the form and doing validation, of course flushing with the bunch of messages because rest of the fields are empty. I remember I had some pages where wrote the code to go on the next field when pressed the Enter button (Tab like), because it didn't go anywhere at all....
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10484
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10251
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10027
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9072
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.