Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

write textfield values to textfile

Status
Not open for further replies.

pugs421

Technical User
Nov 25, 2002
114
US
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
 
You need a server-side script to write to the server. Javascript is a client-side script and doesn't communicate with the server. Use PHP, ASP, or PERL to write the form contents to a file on the server.

There's always a better way. The fun is trying to find it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top