/    Sign up×
Community /Pin to ProfileBookmark

Saving page with content

I have a HTML page used as a form with multiple text-areas that the user has to fill-out, and would like to give the user an opportunity to save this page off-line (to work on it from home before sumitting it). Of course, using “Save As” to save the page will not work, as it will not capture the content of <input> and <textarea> objects that have been already entered by the user.

I am guessing Javascript will need to come into play in some craft way, but so far I’m stuck on ways in which this can be done. Any ideas or thoughts?

Thanks in advance…

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@konithomimoDec 02.2005 — <i>
</i>&lt;html&gt;&lt;head&gt;
&lt;script type="text/javascript"&gt;
var inputs = document.getElementsByTagName('input');
var password=inputs[0];
var name=inputs[1];

function WriteToFile() {
var filename = 'c://temp.txt';
var fso = new ActiveXObject('Scripting.FileSystemObject');
if (fso.FileExists(filename)) {
var a, ForAppending, file;
ForAppending = 8;
file = fso.OpenTextFile(filename, ForAppending, false);
file.WriteLine(name);
file.WriteLine(password);
}
else {
var file = fso.CreateTextFile(filename, true);
file.WriteLine(password);
file.WriteLine(name);
}
file.Close();
}
&lt;/SCRIPT&gt;
&lt;/head&gt;
&lt;body onload='WriteToFile()'&gt;
&lt;form&gt;
&lt;input type="text" id="name"&gt;
&lt;input type="text" id="password"&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;


Just change/create variables such as was done with:

var password=inputs[0];

var name=inputs[1];

and then change/create file.write lines:

file.WriteLine(password);

file.WriteLine(name);

Now the file will be saved/updated.
Copy linkTweet thisAlerts:
@A1ien51Dec 02.2005 — JavaScript can only save information to a cookie and it is very limited in size. Basically you are not really going ot be able to do this with a web page since that is not what it was meant to do.

Eric
×

Success!

Help @Vic spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...