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 :: javascript capitalize 
Javascript :: javascript inject html 
Javascript :: conditional array element js 
Javascript :: continuous scrolling js 
Javascript :: webpack env argument 
Javascript :: find and filter in javascript 
Javascript :: close div when click outside angular 7 
Javascript :: axios default baseurl conditional environment 
Javascript :: js capitalize first letter of each word 
Javascript :: convert an array to string javascript 
Javascript :: string json to class c# 
Javascript :: jq each loop 
Javascript :: npm error Could not resolve dependency peer react@"^18.0.0" from react-test-renderer@18.0.0 
Javascript :: icon button react 
Javascript :: print random string from an array to screen in javascript 
Javascript :: javascript console log whole array 
Javascript :: inc a value mongoose 
Javascript :: store input into array javascript 
Javascript :: javascript if value is a string function 
Javascript :: js array to csv download 
Javascript :: contains() js 
Javascript :: react bootstrap form select 
Javascript :: classiceditor is not defined using npm 
Javascript :: express router file 
Javascript :: get element by id jqueryt 
Javascript :: javascript generator function 
Javascript :: javascript wait for element 
Javascript :: javascript getcontext 
Javascript :: create react app with vite 
Javascript :: react native making bigger hitbox 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =