Click here to Skip to main content
15,879,613 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
i am developing mobile web app for conducting survey in html5. i need to save user responses in file preferably in csv format. How can do it? i am stuck with storing part.......... please please help me.

I cannot use activex for dat purpose coz app needs to work on android+ windows tablet.

thanx in advance.
Posted
Updated 13-Apr-17 16:52pm
v5

Does this[^] help?
 
Share this answer
 
<script language="Javascript">
function download(filename, text) {
  var pom = document.createElement('a');
  pom.setAttribute('href', 'data:text/plain;charset=utf-8,' + 

encodeURIComponent(text));
  pom.setAttribute('download', filename);

  pom.style.display = 'none';
  document.body.appendChild(pom);

  pom.click();

  document.body.removeChild(pom);
}

function addTextHTML()
{
    document.addtext.name.value = document.addtext.name.value + ".html"
}

function addTextTXT()
{
    document.addtext.name.value = document.addtext.name.value + ".txt"
}
</script>




<form name="addtext" onsubmit="download(this['name'].value, this['text'].value)">

<textarea rows="10" cols="70" name="text" placeholder="Type your text here:"></textarea>
<br>
<input type="text" name="name" value="" placeholder="File Name">
<input type="submit" onclick="addTextHTML();" value="Save As HTML">
<input type="submit" onclick="addTexttxt();" value="Save As TXT">

</form>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900