473,399 Members | 3,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

remember form field input over reloads

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
3 2607
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
>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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: A.Kelly | last post by:
Two problems that I'm having (due to being a n00bie) are: The form I'm using is the basic form with a username, email address etc.. the two that I'm most concerned about are the Gender, and...
2
by: JJ | last post by:
Hi All, When someone selects a value in a select on a form I want to show the same form with another select with certain values depending on first select. How can I do this? Should I keep...
13
by: Kai Grossjohann | last post by:
I have a web app which comprises different frames: a menu bar frame, a search form frame, a result list frame. Depending on the state, only a subset of these frames is available. (Eg, after...
7
by: Grant Merwitz | last post by:
Hi I am trying to get the enter key to submit my login form The login form is currently in a control on the page and uses an asp:imagebutton as it's login button. If a user presses enter...
5
by: johnny | last post by:
hi all, I wonder if I could do the following task in PHP before searching for javascript which I prefer not to have in my code: I have a form to create new tables in a database and, since I...
2
by: Shakun | last post by:
Hi All, This is my 1st posting to this group. Can any1 help me with the "Remember Me" which is there in a login form. Im pasting the code below. Im not able to set a cookie.. Thanks, Shakun...
1
by: AC | last post by:
Hi, I have the following code for my form, which is supposed to update a grade integer field and a text area, but when I click the submit button, instead of sending the user to the page...
2
by: semi_evil | last post by:
Hi, I have recently taken up PHP programming, and I got stuck on the following. <? $p_body = (isset ($_POST) && ($_POST != '')) ? $_POST : 'Enter your text here'; $p_name = (isset ($_POST) &&...
5
by: g | last post by:
Hi Guys.. i know this might sound really really simple, but I'm kinda stuck..I have this form..which has a table (created from stored procedure values)..once the table is populated..i have some...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.