在不使用网络服务器的情况下将html表单数据写入txt文件 [英] Writing html form data to a txt file without the use of a webserver

查看:218
本文介绍了在不使用网络服务器的情况下将html表单数据写入txt文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否存在一种使用脚本但不使用网络服务器,webhost,wamp,xamp等将html表单数据提交/写入txt文件的方法.

I was wondering if there is a way to submit/write html form data to a txt file with the use of scripts but with out using a webserver, webhost, wamp, xamp etc.

我一直在尝试使用php脚本,但是他们只是在提交时打开php文档.

I have been trying with php scripts but they just open the php document on submitting.

感谢您的帮助:D

推荐答案

您可以使用JavaScript:

<script type ="text/javascript">
 function WriteToFile(passForm) {

    set fso = CreateObject("Scripting.FileSystemObject");  
    set s = fso.CreateTextFile("C:\test.txt", True);
    s.writeline(document.passForm.input1.value);
    s.writeline(document.passForm.input2.value);
    s.writeline(document.passForm.input3.value);
    s.Close();
 }
  </script>

如果这不起作用,则可以使用ActiveX对象:

If this does not work, an alternative is the ActiveX object:

<script type = "text/javascript">
function WriteToFile(passForm)
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var s = fso.CreateTextFile("C:\\Test.txt", true);
s.WriteLine(document.passForm.input.value);
s.Close();
}
</script>

不幸的是,据我所知,ActiveX对象仅在IE中受支持.

Unfortunately, the ActiveX object, to my knowledge, is only supported in IE.

这篇关于在不使用网络服务器的情况下将html表单数据写入txt文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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