1function WriteToFile(passForm) {
2
3 set fso = CreateObject("Scripting.FileSystemObject");
4 set s = fso.CreateTextFile("<your Path>/filename.txt", True);
5
6 var firstName = document.getElementById('FirstName');
7 var lastName = document.getElementById('lastName');
8
9 s.writeline("First Name :" + FirstName);
10 s.writeline("Last Name :" + lastName);
11
12 s.writeline("-----------------------------");
13 s.Close();
14 }
15
16// HTML
17<form onSubmit="WriteToFile(this)">
18<label>Type your first name:</label>
19<input type="text" name="FirstName" id="firstName" size="20">
20
21<label>Type your last name: </abel>
22<input type="text" name="LastName" id="lastName" size="20">
23
24<input type="submit" value="submit">
25</form>
1<script>
2// Requiring fs module in which
3// writeFile function is defined.
4const fs = require('fs')
5
6// Data which will write in a file.
7let data = "Learning how to write in a file."
8
9// Write data in 'Output.txt' .
10fs.writeFile('Output.txt', data, (err) => {
11
12 // In case of a error throw err.
13 if (err) throw err;
14})
15</script>