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

Save html-forms data to local disk?

P: n/a
A question on html-forms:

We have an application where users will get a CD with,
among other things, some html-forms for them to fill in.
When they click the submit-button, the data is transferred
to a webserver php-script that will then process the info.
The forms-definition looks something like this:

<form action="http://www.ourdomain.com/receiver.php" method="post">
<p>Question 1:
<p><textarea name="reply01" cols="40" rows="5"></textarea>
<p>Question 2:
<p><textarea name="reply02" cols="40" rows="5"></textarea>
<p>Question 3:
<p><textarea name="reply03" cols="40" rows="5"></textarea>
... etc ...
<p><input type="submit" value="Submit answers!">
</form>

Now, my concern is (since there might be quite a lot of data filled in),
if e.g. the internet-connection for some reason is broken
at the moment when the user clicks the submit-button,
there is a risk they will lose all the text and would have to re-type it,
which I would like to avoid, of course.

How can I best solve this issue?

Ideally, I would like to store the info on their local C: drive
before submitting, and automatically retrieve the text if they
later return to the page, but I guess that's not possible from
an html doc, right?

If so, any other suggestions how to resolve this issue?

TIA,
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
I noticed that Message-ID:
<16**************************@posting.google.com > from grz02 contained
the following:
Ideally, I would like to store the info on their local C: drive
before submitting, and automatically retrieve the text if they
later return to the page, but I guess that's not possible from
an html doc, right?
Don't think so.
If so, any other suggestions how to resolve this issue?


Submit each text area separately? Possibly on separate pages with a
bit of javascript to take you to the next page.

Of course if you need an internet connection to do this the page could
come from the server with just a link on the CD.

Then after submitting each textarea separately, you could repopulate it
with the data

<p><textarea name="reply01" cols="40" rows="5"><?php print
$_POST['reply01']; ?></textarea>

etc...
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #2

P: n/a
Trying saving the data into the cookie using Javascript.

Uzytkownik "grz02" <gr***@spray.se> napisal w wiadomosci
news:16**************************@posting.google.c om...
A question on html-forms:

We have an application where users will get a CD with,
among other things, some html-forms for them to fill in.
When they click the submit-button, the data is transferred
to a webserver php-script that will then process the info.
The forms-definition looks something like this:

<form action="http://www.ourdomain.com/receiver.php" method="post">
<p>Question 1:
<p><textarea name="reply01" cols="40" rows="5"></textarea>
<p>Question 2:
<p><textarea name="reply02" cols="40" rows="5"></textarea>
<p>Question 3:
<p><textarea name="reply03" cols="40" rows="5"></textarea>
... etc ...
<p><input type="submit" value="Submit answers!">
</form>

Now, my concern is (since there might be quite a lot of data filled in),
if e.g. the internet-connection for some reason is broken
at the moment when the user clicks the submit-button,
there is a risk they will lose all the text and would have to re-type it,
which I would like to avoid, of course.

How can I best solve this issue?

Ideally, I would like to store the info on their local C: drive
before submitting, and automatically retrieve the text if they
later return to the page, but I guess that's not possible from
an html doc, right?

If so, any other suggestions how to resolve this issue?

TIA,

Jul 17 '05 #3

P: n/a
Thanks for hint, seems like cookie could do the trick then...

Unfortunately, I dont have much experience w client-side scripting,
could someone please provide or point me to some sample-code
I could elaborate on here?

Thanks,
"Chung Leong" <ch***********@hotmail.com> wrote in message news:<GO********************@comcast.com>...
Trying saving the data into the cookie using Javascript.

Jul 17 '05 #4

P: n/a
Found some very helpful code here:
http://www.echoecho.com/jscookies02.htm
so that problem is basically solved now.

But just realized I have a follow-up Question:

By experiment, it seems if I have two different
html-docs in the same local directory, say c:\dir
they will share the same cookie-string.

But if I have two html-docs in different local directories,
say c:\dir1 and c:\dir2 , they will have different cookie-strings
stored independently.

So the Question now is:

Is there any way to define a "global" cookie that will
be shared by all documents stored on the local drive,
regardless of the different directory-paths?

And where can I find some documentation that describes
such implementational details?

Thanks,
Jul 17 '05 #5

P: n/a
You can set the domain of the cookie. Try this cookie API. Can't remember
where I got it from...

<SCRIPT LANGUAGE="JavaScript">
<!--

// name - name of the cookie
// value - value of the cookie
// [expires] - expiration date of the cookie (defaults to end of current
session)
// [path] - path for which the cookie is valid (defaults to path of calling
document)
// [domain] - domain for which the cookie is valid (defaults to domain of
calling document)
// [secure] - Boolean value indicating if the cookie transmission requires a
secure transmission
// * an argument defaults when it is assigned null as a placeholder
// * a null placeholder is not required for trailing omitted arguments
function setCookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
document.cookie = curCookie;
}

// name - name of the desired cookie
// * return string containing value of specified cookie or null if cookie
does not exist
function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else
begin += 2;
var end = document.cookie.indexOf(";", begin);
if (end == -1)
end = dc.length;
return unescape(dc.substring(begin + prefix.length, end));
}

// name - name of the cookie
// [path] - path of the cookie (must be same as path used to create cookie)
// [domain] - domain of the cookie (must be same as domain used to create
cookie)
// * path and domain default if assigned null or omitted if no explicit
argument proceeds
function deleteCookie(name, path, domain) {
if (getCookie(name)) {
document.cookie = name + "=" +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
}

// date - any instance of the Date object
// * hand all instances of the Date object to this function for "repairs"
function fixDate(date) {
var base = new Date(0);
var skew = base.getTime();
if (skew > 0)
date.setTime(date.getTime() - skew);
}

// -->
</SCRIPT>
Uzytkownik "grz02" <gr***@spray.se> napisal w wiadomosci
news:16**************************@posting.google.c om...
Found some very helpful code here:
http://www.echoecho.com/jscookies02.htm
so that problem is basically solved now.

But just realized I have a follow-up Question:

By experiment, it seems if I have two different
html-docs in the same local directory, say c:\dir
they will share the same cookie-string.

But if I have two html-docs in different local directories,
say c:\dir1 and c:\dir2 , they will have different cookie-strings
stored independently.

So the Question now is:

Is there any way to define a "global" cookie that will
be shared by all documents stored on the local drive,
regardless of the different directory-paths?

And where can I find some documentation that describes
such implementational details?

Thanks,

Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.