1

I have created an interactive quiz using html and javascript which will be run on a touchscreen at an event and I need to write the results to a local csv file (so no internet connection). It needs to write to an already existing file, so it cannot be done where the data is stored locally and a download link is generated through the browser.

How would I go about doing this? All methods I have found are either unreliable or no longer supported. The browser I am using is Chrome, so it does not need to be cross-browser compatible.

Can anybody help or point me in the right direction please?

user1391152
  • 1,259
  • 3
  • 13
  • 28

2 Answers2

1

Install a web server.

Point the browser at http://localhost.

Send the data to the server using Ajax or a form submission.

Process the data (including storing it in a file) using the server side language of your choice.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • Unfortunately it needs to function in a way so the client can launch it easily, without the need of installing a localhost web server. No way the client can do this, as I myself will not have access to the actual machine running this thing. I'm starting to think that I may have to resort to actionscript, as I will run into less security issues. – user1391152 Apr 19 '17 at 08:59
  • 1
    @user1391152 — So write them a web server they can launch without doing anything complicated. http://stackoverflow.com/questions/8173232/how-to-make-exe-files-from-a-node-js-app could be a good starting point. – Quentin Apr 19 '17 at 09:01
-1

When javascript is used only in the client-side cannot write data as you want.

Follow the @Quentin recommendation about install some web server, as apache using php for instance(It is pretty straight forward!). I also recommend you to create restFull methods to do it with jquery calls from the client side, it is easy to find many examples in the internet and quicky...

If you want something more easy you could work with html post using forms in php, the most easy way to do it.

Vitorlui
  • 760
  • 1
  • 11
  • 26
  • Javascript is used only in the client side — [that isn't true](https://en.wikipedia.org/wiki/Server-side_JavaScript_implementations) – Quentin Apr 19 '17 at 08:59
  • In this case he doesn't want any js server side, it clearly, anyway I'll edit it because you are right I cannot write in this way. – Vitorlui Apr 19 '17 at 09:15