Hello,
I need a piece of javascript that will allow a form to be submitted
when Enter is pressed for IE6 and 7, Firefox 2, and recent versions of
Safari. It is for a login page that has two textboxes: a "Login" and
a "Password". The "Login Button" is actually a standard image with an
onClick event handler to submit the form, because we use a mouseover
effect. (That is, it is not INPUT TYPE="IMAGE" but rather an IMAGE
tag with onclick="docume nt.forms[0].submit()" added.)
I found some code that works in IE, which is below, but it only works
in IE. I am sure there is a simple cross-browser fragment of
Javascript that will do the trick, so please point me in the right
direction.
Here is the code I am using that only works for IE.
....
<head>
<script type="text/javascript">
function handle_keypress (e)
{
if(window.event .keyCode==13)
{
delayed_submit_ form()
}
else
return false;
}
</script>
</head>
<body onKeyPress="han dle_keypress(ev ent)">
....
Thanks for any help you can give me,
Matt Garvin 2 11748
On Feb 8, 12:58 pm, mattgar...@gmai l.com wrote:
Hello,
I need a piece of javascript that will allow a form to be submitted
when Enter is pressed for IE6 and 7, Firefox 2, and recent versions of
Safari. It is for a login page that has two textboxes: a "Login" and
a "Password". The "Login Button" is actually a standard image with an
onClick event handler to submit the form, because we use a mouseover
effect. (That is, it is not INPUT TYPE="IMAGE" but rather an IMAGE
tag with onclick="docume nt.forms[0].submit()" added.)
I found some code that works in IE, which is below, but it only works
in IE. I am sure there is a simple cross-browser fragment of
Javascript that will do the trick, so please point me in the right
direction.
Here is the code I am using that only works for IE.
...
<head>
<script type="text/javascript">
function handle_keypress (e)
{
if(window.event .keyCode==13)
{
delayed_submit_ form()
}
else
return false;
}
</script>
</head>
<body onKeyPress="han dle_keypress(ev ent)">
...
Thanks for any help you can give me,
Matt Garvin
I am not so sure about Safari but for ie and firefox I know that the
following works:
<html>
<script language="javas cript">
function myKeyPressed(e) {
e = e || window.event;
var unicode=e.charC ode ? e.charCode : e.keyCode ? e.keyCode : 0;
if (unicode == 13){
document.formna me.submit();
}
}
document.onkeyp ress = myKeyPressed;
</script>
<body>
<form name="formname" action="#" method="get">
<input name="test" type="text" value="test" size="12" />
</form>
</body>
</html>
Thank you for the code, Adam.
I tested it, and indeed it did work with IE and FF. Like you, I have
yet to test it with Safari, but it is covering the two biggies now.
Thank you,
Matt Garvin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Dave Smithz |
last post by:
Hi,
In summary:
I want to a form to submit information via a HTTP POST, however, when using
Internet Explorer I want to be able to use the back button and all the
information retained. Presently we get a "Page has expired" message. How can
we avoid this?
Full details:
Having searched for postings on how to avoid the "Page has Expired" they are
|
by: Simon Wigzell |
last post by:
Is there a way to prevent a form submitting when you press enter on a text
field? Some people press enter when they finish typing in a text field out
of habit I guess unconcsciously thinking it will take them to the next
field. Instead it submits the form and this causes all kinds of problems in
my case. Any javascript solution?
|
by: Questman |
last post by:
Good afternoon,
Does anyone have any code that implements, or approaches implementing, a
cross-browser DHTML/JS solution to provide an Excel-like Grid on a web
page - I'm trying to convert an old Java client/server data maintenance
program to the web - the main display is in a grid format, which allows
the user to select multiple rows and edit them in a new grid, which
processes each grid line individually and validates and saves the...
|
by: Jared |
last post by:
I'd like to display a "please wait while your file is uploading" page
immediately after someone uploads a large-ish file. I know I could
make something really slick with DHTML, or even something semi-slick
using a hidden frame to post the form to. However, both of these
approaches carry browser-compatibility risks.
It's my understanding that my server-side code doesn't execute until
the file is completely received by IIS, so I can't...
|
by: laredotornado |
last post by:
Hi,
I have a very simple form and I would like on Firefox and IE for the
form to submit upon the user pressing enter in the textfield. Right
now, I have
<script type="text/javascript">
function search() {
var search = document.getElementById('Search');
location = "search_response.php?Search=" + escape(search.value);
| |
by: huckfinn19 |
last post by:
Hi all,
I am using C# 2.0.
Here is my problem. I have a modal form with an OK button. When the user, using tabs, activates the OK button and presses "Enter", in the Button event, I call:
this.DialogResult=DialogResult.OK;
This closes my modal form fine.
|
by: Zytan |
last post by:
I can handle DoubleClick on a ListBox to respond, not when the
selection changes, but when you double click one to invoke an action.
This is the same as using the keys to move the selection, then
pressing Enter. But, of course, DoubleClick doesn't automatically
handle that.
Is there any way to handle ALL standard UI at once, rather than
checking for DoubleClick and for Enter press manually?
Zytan
|
by: white lightning |
last post by:
How to have <select onchange="this.form.submit()"and also a Submit
button on one form?
I have something like this:
<form action="<?php $_SERVER; ?>" method="post"
enctype="multipart/form-data" name="form1">
<select onchange="this.form.submit();" name="prod">
<option value="">Select product</option>
<option value="12">abc</option>
|
by: abcdriver |
last post by:
<form name="return" method="post" action="a.jsp">
<input type="hidden" name="name" value="bb">
</form>
<script language="JavaScript" type="text/javascript">
document.return.submit();
</script>
The code makes an auto-submit form.
|
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...
|
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,...
| |
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...
|
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...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |