将Html5表单数据保存到文本文件。 [英] Save Html5 Form data to text file.

查看:611
本文介绍了将Html5表单数据保存到文本文件。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发用于在html5中进行调查的移动网络应用程序。我需要将文件中的用户响应保存为csv格式。怎么办?我被困在存储部分..........请帮助我。



我不能将activex用于dat目的coz app需要在android + windows平板电脑上运行。



thanx提前。

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.

推荐答案

这个 [< a href =http://www.w3schools.com/html5/html5_webstorage.asptarget =_ blanktitle =New Window> ^ ] 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>


这篇关于将Html5表单数据保存到文本文件。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆