Does Javascript able save html form to file?

possible for html form run on PC and save data to disk

Page 1 of 1

4 Replies - 17456 Views - Last Post: 12 March 2009 - 11:37 PM

#1 jilong  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 33
  • Joined: 17-May 07

Does Javascript able save html form to file?

Posted 17 May 2007 - 09:25 PM

I would like to create a html E-test form run on PC and the data will save into a file on disk.

I search online for this function code but found that most the script only save the cookie, is it possible for javascript save form data to file?

Here is the ideal for my survay form,
1. user click "start" button for the e-test,
2. user need to finish the e-test with in 20 minutes, after 20 minutes the form will auto submit and the data will save into file,
3. me will go to the file folder open it and print out the qestion and anwser.
4. The file will be detele after i print out and the next user can do the e-test again.

I got the time counter and the auto submit script. but i just have no ideal how to save the data into file.

can someone pleave give me a guide or ideal to do this?

Is This A Good Question/Topic? 0
  • +

Replies To: Does Javascript able save html form to file?

#2 girasquid  Icon User is offline

  • Barbarbar
  • member icon

Reputation: 108
  • View blog
  • Posts: 1,825
  • Joined: 03-October 06

Re: Does Javascript able save html form to file?

Posted 18 May 2007 - 04:59 AM

Javascript alone can't save data to a file. If you want to do this you'll probably need to use a little bit of Ajax along with a server-side script to write the data to a file for you.
Was This Post Helpful? 0
  • +
  • -

#3 cyclonmaster  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 11-March 09

Re: Does Javascript able save html form to file?

Posted 11 March 2009 - 11:25 PM

Hi Jilong. Do you manage to solve your problem yet? I also want to create an e-test web.
Was This Post Helpful? 0
  • +
  • -

#4 NickDMax  Icon User is offline

  • Can grep dead trees!
  • member icon

Reputation: 2250
  • View blog
  • Posts: 9,245
  • Joined: 18-February 07

Re: Does Javascript able save html form to file?

Posted 12 March 2009 - 06:02 AM

javascript running in a browser by itself cannot write to the local harddrive -- this is a security feature.

There are a number of ways that you can save data though:

Generally you can send data back to the server and then the sever can save the data (you don't even have to use ajax). In fact this is normally how such things are done. This does add the wrinkle of needing to keep track of users and sessions on the server.

You can also use a cookie. This allows you to save a set of name-value pairs on the client. However don't let such things bother you. to save complex data people often base64 encode the data and then make the cookie a name value pair such as: "data=AG475gS6s63jx83&sheGE3432..." -- you can save up to 4k in 1 cookie.

You can send the data to the user as a file for them to download -- they will have to choose where to save the data, and when it comes time to load the data they will have to find it for you again (so that it can be uploaded to your server) -- not all that different from a normal app.

You can write your own browser extension to save the data. Often this ends up being a very browser specific solution. There is also a pretty good chance that your extension will be considered mal-ware and eventually found and removed by virus scanners or spyware scanners because it would enable a page to violate security. -- even if you don't use it for evil others might.

now all of the above assume that you meant javascript running in a browser -- now if you just mean javascript running in a scripting host -- well in that case (depending upon local security settings) you should be able to get ahold of a filesystem object and write a file to the file system... but this WILL NOT work from within a browser (or on a system where security settings don't allow it).

This post has been edited by NickDMax: 12 March 2009 - 06:03 AM

Was This Post Helpful? 0
  • +
  • -

#5 cyclonmaster  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 11-March 09

Re: Does Javascript able save html form to file?

Posted 12 March 2009 - 11:37 PM

This is my quiz test sample code[attached]. I want to store the data either in access or excel or any other way to store the name and score of each person. i'm using wampserver. Any guide to use wampserver as my server? I had setup my Lan local forum using wampserver+mybb. I hope wampserver can be use for this. Thanks for any guide.

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1