469,572 Members | 1,213 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,572 developers. It's quick & easy.

curson focus to end of text on form field

Hello.

I've got this page that refreshes automatically and I am able to set
the focus on a specific field at page load with. However the cursor
goes back to position 1. In some cases my users will be in the middle
of typing when a refresh occurs. How do get the cursor back to the
position it was in when the refresh took place?

Here's how I set focus:

document.getElementById('namehere').focus();

Keep in mind the refresh is driven by a javascript timeout call to

document.mydoc.submit() ;

Thanks for any help or information!
Jul 20 '05 #1
1 2809
In article <ef**************************@posting.google.com >,
ja***@cyberpine.com enlightened us with...
Hello.

I've got this page that refreshes automatically and I am able to set
the focus on a specific field at page load with. However the cursor
goes back to position 1. In some cases my users will be in the middle
of typing when a refresh occurs. How do get the cursor back to the
position it was in when the refresh took place?

You can't without a lot of BS (session vars or cookies or get params
with the form). A submit of a form loads the page new from the server,
losing all running JS code. The only reason the form values are still
there is because of browser settings. Some browsers will also clear the
fields completely with a form submit.

Now, if it were me, I wouldn't refresh in the middle of someone typing,
but hey, that's just me.
--
--
~kaeli~
Bakers trade bread recipes on a knead-to-know basis.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by 'bonehead | last post: by
2 posts views Thread by fish | last post: by
11 posts views Thread by JCO | last post: by
1 post views Thread by Jens Körte | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.