I have code that writes the values entered into the textfields on a form into a text file. The problem is that it only works when the file is saved locally. It doesn't seem to work on a server or even a network drive.
I was wondering if it is possible to accomplish this goal, but allowing the page to run on the server. Perhaps getting the values using javascript and passing them to vbscript? I don't understand why I'm having this problem since Javascript is client side code, right? Here's the code (works locally , not on server):
<html>
<head>
<title>Untitled Document</title>
<script language="javascript">
function save_text_js()
{
var file_location = "c:/info.csv";
var fs = new ActiveXObject("Scripting.FileSystemObject");
file = fs.OpenTextFile(file_location, 8, true);
file.write(document.getElementById("idCardName").value);
file.write(",");
file.write(document.getElementById("firstName").value);
file.write(",");
file.write(document.getElementById("lastName").value);
file.write(",");
file.writeline(document.getElementById("address").value);
file.close();
}
</script>
</head>
<body>
<form name="anything">
<p><input name="idCardName" type="text" id="idCardName"></p>
<p><input name="firstName" type="text" id="firstName"></p>
<p><input name="lastName" type="text" id="lastName"></p>
<p><input name="address" type="text" id="address"></p>
<p><input type="button" onClick="save_text_js()" value="Add data to text file."> </p>
</form>
</body>
</html>
Thanks
I was wondering if it is possible to accomplish this goal, but allowing the page to run on the server. Perhaps getting the values using javascript and passing them to vbscript? I don't understand why I'm having this problem since Javascript is client side code, right? Here's the code (works locally , not on server):
<html>
<head>
<title>Untitled Document</title>
<script language="javascript">
function save_text_js()
{
var file_location = "c:/info.csv";
var fs = new ActiveXObject("Scripting.FileSystemObject");
file = fs.OpenTextFile(file_location, 8, true);
file.write(document.getElementById("idCardName").value);
file.write(",");
file.write(document.getElementById("firstName").value);
file.write(",");
file.write(document.getElementById("lastName").value);
file.write(",");
file.writeline(document.getElementById("address").value);
file.close();
}
</script>
</head>
<body>
<form name="anything">
<p><input name="idCardName" type="text" id="idCardName"></p>
<p><input name="firstName" type="text" id="firstName"></p>
<p><input name="lastName" type="text" id="lastName"></p>
<p><input name="address" type="text" id="address"></p>
<p><input type="button" onClick="save_text_js()" value="Add data to text file."> </p>
</form>
</body>
</html>
Thanks