curson focus to end of text on form field

J

jason

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!
 
K

kaeli

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.


--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top