Connecting Tech Pros Worldwide Help | Site Map

Keep focus after submit

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 20th, 2005, 09:08 AM
Robert Scheer
Guest
 
Posts: n/a
Default 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='Javascript'>
function checkaddress(txt)
{
if (txt.value.length == 1) {
document.Form1.optAdd.checked=true;
document.Form1.submit();
txt.focus(); }
else { return false; }
}
</Script>


Thanks,

Robert Scheer

  #2  
Old July 20th, 2005, 09:08 AM
Grant Wagner
Guest
 
Posts: n/a
Default Re: Keep focus after submit

Robert Scheer wrote:
[color=blue]
> 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='Javascript'>
> function checkaddress(txt)
> {
> if (txt.value.length == 1) {
> document.Form1.optAdd.checked=true;
> document.Form1.submit();
> txt.focus(); }
> else { return false; }
> }
> </Script>
>
> Thanks,
>
> Robert Scheer[/color]

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 <gwagner@agricoreunited.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


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.