Javascript 存储</输入>;数据到主机
我正在使用HTML和JavaScript,我有一个关于使用Javascript 存储</输入>;数据到主机,javascript,html,Javascript,Html,我正在使用HTML和JavaScript,我有一个关于使用元素的问题,这是我的输入之一: <input size="4" class="PanInput" id="W_PAN4" name="W_PAN4" maxlength="4" autocomplete="off" onkeypress="return numericOnKeypress(event)" onkeyup="nextTabs(this, false, event)" value="" tabindex="1" dir=
元素的问题,这是我的输入之一:
<input size="4" class="PanInput" id="W_PAN4" name="W_PAN4" maxlength="4" autocomplete="off" onkeypress="return numericOnKeypress(event)" onkeyup="nextTabs(this, false, event)" value="" tabindex="1" dir="ltr" onpaste="doNotPaste()" onfocus="getName(this)" type="text" width="200">
我希望有一个类似于此的函数:
<script type="text/javascript">
function WriteToFile(passForm) {
set fso = CreateObject("Scripting.FileSystemObject");
set s = fso.CreateTextFile("Location_Here", True);
s.writeline(document.passForm.input1.value);
s.writeline(document.passForm.input2.value);
s.writeline(document.passForm.input3.value);
s.Close();
}
</script>
函数WriteToFile(passForm){
设置fso=CreateObject(“Scripting.FileSystemObject”);
设置s=fso.CreateTextFile(“Location_Here”,True);
s、 writeline(document.passForm.input1.value);
s、 writeline(document.passForm.input2.value);
s、 writeline(document.passForm.input3.value);
s、 Close();
}
我的意思是,我想将这些输入数据存储为本地主机甚至在线主机上的.txt
文件
保存这些数据的最简单方法是什么?格式并不重要,我可以处理任何电子邮件、文件等。我认为这是一项服务器端工作。欢迎使用任何代码。建议使用数据库存储此数据。根据您的技术堆栈,可能是MongoDB、MySQL等。使用客户端JS写入文件一点也不安全(如果可能的话?),因此您需要进行一些服务器端处理来处理表单提交(可以是node.JS,而不是客户端)。使用php生成这些txt文件。@a.meshu如何?
<script type="text/javascript">
function WriteToFile(passForm) {
set fso = CreateObject("Scripting.FileSystemObject");
set s = fso.CreateTextFile("Location_Here", True);
s.writeline(document.passForm.input1.value);
s.writeline(document.passForm.input2.value);
s.writeline(document.passForm.input3.value);
s.Close();
}
</script>