7 Replies - 9344 Views - Last Post: 16 May 2012 - 05:49 PM

#1 weraw  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 15-May 12

How to create text file using javascript.

Posted 15 May 2012 - 01:42 AM

Hye to everyone..

hye..im trying to create txt file in local directory using javascript, it is possible?? im already searched about it. but most of information said about ActiveXObject. from what i knew that ActiveXObject only can be use in internet Explorer..

Thank You in advance :helpsmilie:

Is This A Good Question/Topic? 0
  • +

Replies To: How to create text file using javascript.

#2 g00se  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2148
  • View blog
  • Posts: 8,926
  • Joined: 20-September 08

Re: How to create text file using javascript.

Posted 15 May 2012 - 02:29 AM

Not easy. What is your goal?

http://technojeeves....smart-questions

This post has been edited by g00se: 15 May 2012 - 02:29 AM

Was This Post Helpful? 1
  • +
  • -

#3 weraw  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 15-May 12

Re: How to create text file using javascript.

Posted 15 May 2012 - 06:12 PM

View Postg00se, on 15 May 2012 - 02:29 AM, said:

Not easy. What is your goal?

http://technojeeves....smart-questions



Yah Mr goose. i create one drawing application. for now for saving im trying to save the .html using html() in text file to be save in user profile folder for reload. :dozingoff:
Was This Post Helpful? 0
  • +
  • -

#4 JulianNeill  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 13
  • Joined: 15-May 12

Re: How to create text file using javascript.

Posted 15 May 2012 - 06:55 PM

Try this-->
If you need any explanation let me know
Change the "C:\test.txt" to your directory where you wanna store it

<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> 


Was This Post Helpful? 1
  • +
  • -

#5 weraw  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 15-May 12

Re: How to create text file using javascript.

Posted 15 May 2012 - 07:14 PM

View PostJulianNeill, on 15 May 2012 - 06:55 PM, said:

Try this-->
If you need any explanation let me know
Change the "C:\test.txt" to your directory where you wanna store it

<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> 



i'm already tried it this code but it still could not working.. chrome said that has problem with set fso = CreateObject("Scripting.FileSystemObject"); .. Thank you Mr.
Was This Post Helpful? 0
  • +
  • -

#6 JMRKER  Icon User is offline

  • D.I.C Addict

Reputation: 115
  • View blog
  • Posts: 751
  • Joined: 25-October 08

Re: How to create text file using javascript.

Posted 16 May 2012 - 08:14 AM

View Postweraw, on 15 May 2012 - 08:14 PM, said:

...

i'm already tried it this code but it still could not working.. chrome said that has problem with set fso = CreateObject("Scripting.FileSystemObject"); .. Thank you Mr.


This probably only works in MSIE and will definitely do nothing on the internet as your local file will not be available to anyone but your local computer.
:gun_bandana:
Was This Post Helpful? 1
  • +
  • -

#7 JulianNeill  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 13
  • Joined: 15-May 12

Re: How to create text file using javascript.

Posted 16 May 2012 - 09:20 AM

View PostJMRKER, on 16 May 2012 - 08:14 AM, said:

View Postweraw, on 15 May 2012 - 08:14 PM, said:

...

i'm already tried it this code but it still could not working.. chrome said that has problem with set fso = CreateObject("Scripting.FileSystemObject"); .. Thank you Mr.


This probably only works in MSIE and will definitely do nothing on the internet as your local file will not be available to anyone but your local computer.
:gun_bandana:



Well you can create a folder within where your website is saved and call it "texts"
and instread of "C:" just do "/texts" and save it that way.
I was only using Local (C:) as a example not the correct way.
But thanks for clarifying a little.

and I do think the code I posted on works for IE, since Chrome and IE has different backbone setups.

Sorry I couldnt Help anymore then I did.
Was This Post Helpful? 0
  • +
  • -

#8 weraw  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 15-May 12

Re: How to create text file using javascript.

Posted 16 May 2012 - 05:49 PM

View PostJulianNeill, on 16 May 2012 - 09:20 AM, said:

View PostJMRKER, on 16 May 2012 - 08:14 AM, said:

View Postweraw, on 15 May 2012 - 08:14 PM, said:

...

i'm already tried it this code but it still could not working.. chrome said that has problem with set fso = CreateObject("Scripting.FileSystemObject"); .. Thank you Mr.


This probably only works in MSIE and will definitely do nothing on the internet as your local file will not be available to anyone but your local computer.
:gun_bandana:



Well you can create a folder within where your website is saved and call it "texts"
and instread of "C:" just do "/texts" and save it that way.
I was only using Local (C:) as a example not the correct way.
But thanks for clarifying a little.

and I do think the code I posted on works for IE, since Chrome and IE has different backbone setups.

Sorry I couldnt Help anymore then I did.


Thank to all... the problem solved.. i change the concept instead of using javascript to create the text..i asked for help from Mr. Python to create where i parse the string using ajax..

Thank You All. :punk:
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1