473,769 Members | 1,618 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Keep focus after submit

Hi.

I have a function to submit the form when my user types any character
on a textbox. I call the function on the keyup event of the textbox.
The function submits the form and set the focus on the textbox, after
the submit. The form submits ok, but after the submit the focus won't
return to the textbox. Can anyone help me to solve that problem?
That's the function:

<Script language='Javas cript'>
function checkaddress(tx t)
{
if (txt.value.leng th == 1) {
document.Form1. optAdd.checked= true;
document.Form1. submit();
txt.focus(); }
else { return false; }
}
</Script>
Thanks,

Robert Scheer
Jul 20 '05 #1
1 12450
Robert Scheer wrote:
Hi.

I have a function to submit the form when my user types any character
on a textbox. I call the function on the keyup event of the textbox.
The function submits the form and set the focus on the textbox, after
the submit. The form submits ok, but after the submit the focus won't
return to the textbox. Can anyone help me to solve that problem?
That's the function:

<Script language='Javas cript'>
function checkaddress(tx t)
{
if (txt.value.leng th == 1) {
document.Form1. optAdd.checked= true;
document.Form1. submit();
txt.focus(); }
else { return false; }
}
</Script>

Thanks,

Robert Scheer


Once you've submitted the form, you've navigated away from the page.
JavaScript will stop executing and the browser will load the page
specified by the ACTION attribute of the <form> element.

While some browsers may actually execute txt.focus() as the form
submission occurs, it's more of a bug then a feature.

--
| Grant Wagner <gw*****@agrico reunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* Netscape 6/7 DOM Reference available at:
* http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 6/7 and Mozilla
* http://www.mozilla.org/docs/web-deve...upgrade_2.html
Jul 20 '05 #2

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

Similar topics

4
2219
by: Nitin | last post by:
Hi I have created function to check date and time. at the time of execution, if date is left empty the function returns the error message but then the focus goes to next field. Next filed is for time and there is also a check on that. If time is empty return error message. Again the explorer returns error message and then shifts the focus to date field, again error message and focus goes to time and this story goes on and on, untill...
2
1520
by: ungvichian | last post by:
Okay, how do I write a page with a form so that when I click Submit, the following happens? 1. The data is submitted (of course) 2. The form is cleared (what I've tried results in the form being cleared first, resulting in an empty submission), and 3. The cursor goes back to the start of the form, ready for more input (kind of like how Google puts the cursor in the search box at the start).
2
3729
by: jw56578 | last post by:
Is there a reason why setting focus to a textbox input, also gives focus to a submit button on the page, to where if you click enter in the text box, the submit button will be clicked.
2
7786
by: Pawel | last post by:
Hello All I have a submit button in my form. It gets focus (is activated by ENTER) everytime any text inputs are edited. So, if the user press ENTER before finishing all form, the form is submited. I would like to prevent this button to get focus, and make it possible to be activated only by mouse, or by specific tabindex. I have tried to use: <BODY bgcolor="#DBF3A7" onLoad="setfocus()">, where setfocus()
0
1052
by: Chris | last post by:
Hi, I have a dilemma. I have a web form that, when submitted, does a window.open js function to submit the form data to a new aspx page which then shows a report. I wanted to make sure that the first text box control had the focus so I added javascript code to set that focus. The only problem was that the popup window kept opening behind the parent after the submit. So, I added a document.focus() in the onload event of the new...
2
1458
by: barry | last post by:
I was wondering why on a webform when I put the cursor into a textbox the focus goes to the only button on the form. thanks
4
2736
by: Johannes Kiehl | last post by:
Hi group, I've been losing most of my remaining hair today, trying to track down a problem with IE6.0 (builds: .2600 and XP SP 2). I set the border-width of form input fields to 1px via inline CSS. But whenever I call the focus() method of any of the form fields, the border width of the (first) submit button changes to 2px. It doesn't matter whether the focus() method is called
8
1908
by: Nivetha | last post by:
I have requirement like the first page contains LoginName and CompanyName after typing the value clicking Submit button so i am giving in body onload="document.forgotPassword.loginName.focus(); document.forgotPassword.securityAnswer.focus();" bcoz after giving correct value by clicking submit button it is going to the same page with some otherfields like Login Name Coompany Id Security Question Security Answer here i need to focus my...
3
1418
Ajm113
by: Ajm113 | last post by:
Ok for some reason after the update of Firefox it seems that my form keeps getting submitted when the user made a error on the form. I just want the page to reload so the user may try again. Because I have it so the submit button is a hit once only. Here is the code: <SCRIPT LANGUAGE="JavaScript"> function validateForm(form) { if (form.username.value == "")
0
9589
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
9423
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
10211
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...
1
9994
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9863
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
8870
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
6673
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
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.