Capture API: Save Form Data

This API will save data (for example, information entered into a form) to a .csv or text file stored locally on the device.

CSV (comma-separated value) is a standard format compatible with most spreadsheet software, including Microsoft Excel, and is often used as a format for uploading contact data to online databases. When saving in this format, Kiosk Pro saves each entry as a new line and each cell within that line must be delineated by a comma. Entries can also be saved to a plain text (.txt) file.

Functions

Common Questions

Requirements

  • Access JavaScript API
    • By Import - recommended, works both online & offline, requires inclusion of kiosk_functions.js prior to any of the following calls.
    • By Injection - only works offline, may not be available 'onload' event.

Additional Resources

Other file management calls available here.

More information on how to sync the resulting .csv file back to a Dropbox account if you are using our Plus or Enterprise versions is available here.

Sample Code

This sample code relies on the JavaScript APIs built into Kiosk Pro and will not run successfully in other browsers or within our in-app help interface.  
To run sample code, set the app's homepage to http://www.kioskproapp.com/save-form-data

Download Sample Code


writeToFile

This function saves data to a file stored locally in Kiosk Pro's documents folder.

Format
writeToFile(fileName,fileData,callback);
		
Parameters
  • fileName = name of the .csv or .txt file saved to the device as a string, which should include the suffix '.csv' or '.txt'. The filepath defined here (and in the function) is relative to the main Kiosk Pro Documents folder (and not the page calling the function). While it is possible to define a local filepath using folders here (for example, 'testfolder/test.csv'), the folder cannot be automatically generated by the app, but must be manually created prior to running these functions. If you try to save to a folder location that does not exist, the save data call will fail.
  • fileData = the data that is being saved to the device as a string. Multiple pieces of data can be delineated by commas and sent in a single line/request.
  • callback = name of callback function which will be called with the following signature: callback(success).
Callback format
callback(success);
		
Callback return values success = if defined, the function successfully wrote data to the local file named.

Still stuck? How can we help? How can we help?