Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Donate Today!

Do you enjoy these
technical forums?
Donate Today! Click Here

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

saphiroth (Programmer)
2 Jan 06 13:26
Hello,
I'm trying to have a user input their name on a webpage and then have the webpage store that name in a text file on the server.  I have a form on a webpage where a user types their name in and then after pressing submit the name gets saved in a text file.  But for some reason this does not work for me.  Please help!!  Here is my code.
  

CODE

<SCRIPT LANGUAGE="JavaScript">
 function WriteToFile(passForm) {
    
    set fso = CreateObject("Scripting.FileSystemObject");  
    set s = fso.CreateTextFile("C:\test.txt", True);
    s.writeline("HI");
    s.writeline("Bye");
    s.writeline("-----------------------------");
    s.Close();
 }
  </SCRIPT>

</head>

<body>
<p>To sign up for the Excel workshop please fill out the form below:
</p>
<form onSubmit="WriteToFile(this)">
Type your first name:
<input type="text" name="FirstName" size="20">
<br>Type your last name:
<input type="text" name="LastName" size="20">
<br>
<input type="submit" value="submit">
</form>
ca8msm (Programmer)
2 Jan 06 13:44
If you want to create a text file on the server then you'll have to use a server side language (such as ASP, PHP etc).

If you want to create the text file on the client then I think you'll have to use an ActiveX object otherwise you may run into permission problems (you may run into problems anyway as the user may deny you access) e.g.

CODE

<html>
<head>
<script language="javascript">
function WriteToFile()
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var s = fso.CreateTextFile("C:\\Test.txt", true);
s.WriteLine('Hello');
s.Close();
}
</script>
</head>
<body onLoad="WriteToFile()">

</body>
</html>


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

astalmokas (Programmer)
20 Jan 06 12:05
Hello,

I need to create a text file on client side right as ca8msm wrote (I want to write all user input in a text.log before submitting it to server - sometimes the connection to server freezes and a lot of input dissapiers without beeing registered on a server).

BUT, I get an error "[object Error]" with THE first sentence:
 var fso = new ActiveXObject("Scripting.FileSystemObject");

I turned off NIS blocking, checked all Explorer properties about script....
Do I need to enable or install any ActiveX?

 Any suggestions about this error? Thanks in advance
kaht (Programmer)
20 Jan 06 13:55
Either:

1. You're using a non-ie browser (which doesn't support activex objects)

2. you're using an ie browser on an xp machine with sp2 installed and the activex object is being blocked

-kaht

How much you wanna make a bet I can throw a football over them mountains?

astalmokas (Programmer)
21 Jan 06 9:20
Yes, it's XP with sp2, IE6. All options in IE about ActivX are Enabled or Prompt. Maybe some Add-on (ActiveX) must be installed additionaly. Or it must be by default - then what it's name in Add-on list or somewhere else.

Thanx
BillyRayPreachersSon (Programmer)
21 Jan 06 9:21

Are you running this locally, or from a web server? You need to ensure that the settings are correct for the "zone" from which you are running this, AFAIK.

Hope this helps,
Dan

Dan's Page @ Code Couch
http://www.codecouch.com/dan/


Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close