Click here to Skip to main content
14,869,740 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
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?
   
<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>
   
Comments
Kats2512 14-Apr-17 1:41am
   
Do you really think the person who asked the question would still be looking for an answer after 5 long years?

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