By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,480 Members | 1,743 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,480 IT Pros & Developers. It's quick & easy.

remember form field input over reloads

P: n/a
Hi,
I have a page with a form. This form has an input field <textarea>. I
use it to have my users enter text and on form submit it gets inserted
into a db.
Initially there is some standard text shown in the <textarea> ("please
type comments here"). The user types some text, _doesn't_ do a submit,
continues to work. Only when he's finished working, he does a submit.
It's a time-tracking system so it also keeps track of start and
endtimes. Thats why.

So far so good.

Now every 20 minutes I do a refresh of the page (meta tag http refresh
etc). What happens: the text the user typed in gets replaced with
custom text! (remember, he didn't do a submit yet so there's no text
from the db to show). Now I wonder:

Can I somehow save the text user typed in the textarea? - maybe
onBlur=""
Can I save this text then somewhere locally? - Maybe in a hidden field?
Can I have the <textarea> show the contens of this hidden field? - this
would be either the standard text or - if user typed something - the
typed text.
How do I do this?

Thanks!

Oct 6 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
coffee_man wrote:
Hi,
I have a page with a form. This form has an input field <textarea>. I
use it to have my users enter text and on form submit it gets inserted
into a db.
Initially there is some standard text shown in the <textarea> ("please
type comments here"). The user types some text, _doesn't_ do a submit,
continues to work. Only when he's finished working, he does a submit.
It's a time-tracking system so it also keeps track of start and
endtimes. Thats why.

So far so good.

Now every 20 minutes I do a refresh of the page (meta tag http refresh
etc). What happens: the text the user typed in gets replaced with
custom text! (remember, he didn't do a submit yet so there's no text
from the db to show). Now I wonder:

Can I somehow save the text user typed in the textarea? - maybe
onBlur=""
Can I save this text then somewhere locally? - Maybe in a hidden field?
Can I have the <textarea> show the contens of this hidden field? - this
would be either the standard text or - if user typed something - the
typed text.
How do I do this?

Thanks!


Hi Coffeeman,

The easiest way is to remove the http-refresh header and replace the logic
with Javascript.

But first: WHy do you refresh the page? Are you circumventing a
sessiontimeout?
If you are worried about session loss with your server while the webpage is
open, a simple refresh every 20 minutes on some dummypage in a hidden frame
will keep the session alive, while your mainpage stays intact.

Have a look at setTimeout() function to program an event in the future.

Hope this helps.

Regards,
Erwin Moller


Oct 6 '05 #2

P: n/a
>WHy do you refresh the page? Are you circumventing a
sessiontimeout?
yes!
Hope this helps.

Works great! thanks for the tip.

Anyway, what if I want to do this in another situation? How do I
remember input in a textArea on blur?

Oct 6 '05 #3

P: n/a
coffee_man wrote:
WHy do you refresh the page? Are you circumventing a

sessiontimeout?
yes!
Hope this helps.

Works great! thanks for the tip.

Anyway, what if I want to do this in another situation? How do I
remember input in a textArea on blur?


Hi,

Getting the value is simple:
documnet.forms.yourformname.yourtextfieldname.valu e contains it.

How to remember?
Well, the problem is that javascript is limitted to one page.
If you refresh the page, the info that javascript held is gone.
If you need to remember values, you have to make a window that does not
disappear.

A straightforward solution could be: use frames: one hidden (height 0) and 1
normal as you do now.

You can put javascript in both the framedefinitionpage, or in the hidden
frame.
I would suggest you put it in the framedefinitionframe, in that way you will
have the hidden frame available for posting data to your server.

If you want to acces the framedefinitionpage from your current page, use
parent.etc
Now you have a few option. For example: use onUnLoad() to get the value of
the textfield and store it in the parent frame.
Or maybe onBlur. I never used onBlur in this context, so I have no advise.
Or maybe poll the value of the field every second, but that might be a
little over the top.

Hope this helps.

Good luck.

Reagrds,
Erwin Moller
Oct 6 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.