Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

write to file js

// write to js file
const fs = require('fs')

const content = 'this is what i want to write to file'

fs.writeFile('/Users/joe/test.txt', content, err => {
  if (err) {
    console.error(err)
    return
  }
  //file written successfully
})
Comment

javascript write to text file

function WriteToFile(passForm) {
 
    set fso = CreateObject("Scripting.FileSystemObject"); 
    set s   = fso.CreateTextFile("<your Path>/filename.txt", True);
 
    var firstName = document.getElementById('FirstName');
    var lastName  = document.getElementById('lastName');
 
    s.writeline("First Name :" + FirstName);
    s.writeline("Last Name :" + lastName);
 
    s.writeline("-----------------------------");
    s.Close();
 }

// HTML
<form onSubmit="WriteToFile(this)">
<label>Type your first name:</label>
<input type="text" name="FirstName" id="firstName" size="20">
 
<label>Type your last name: </abel>
<input type="text" name="LastName" id="lastName" size="20">
 
<input type="submit" value="submit">
</form>
Comment

PREVIOUS NEXT
Code Example
Javascript :: trim first character in javascript 
Javascript :: how to completely reload page in jquery 
Javascript :: jquery scroll to bottom 
Javascript :: if media query jquery 
Javascript :: set value in span using jquery 
Javascript :: uncheck all radio button jquery 
Javascript :: mongoose model find all documents with ids in array 
Javascript :: check if a variable is array in javascript 
Javascript :: sequelize undo last migration 
Javascript :: Jest encountered an unexpected token 
Javascript :: joi.validate is not a function 
Javascript :: $(document).ready | document.ready 
Javascript :: javascript keypress backspace not working 
Javascript :: us states js array 
Javascript :: string to url javascript 
Javascript :: how can i validate an email address in javascript 
Javascript :: javascript detect mobile device 
Javascript :: nodejs make directory 
Javascript :: username validation in javascript 
Javascript :: react check if string is mail 
Javascript :: detect if scrolled to bottom 
Javascript :: get local storage javascript 
Javascript :: adding event on enter key keypress in javascript 
Javascript :: canvas font colour 
Javascript :: js get string before character 
Javascript :: how to clear nodemon cache 
Javascript :: js change root css variable 
Javascript :: enable version 12 node glitch 
Javascript :: react allow only numbers in input 
Javascript :: nodejs open default browser on specific web page 
ADD CONTENT
Topic
Content
Source link
Name
2+1 =