Answered step by step
Verified Expert Solution
Question
1 Approved Answer
javascript when I click the submit button, I want to store it in the text file (.txt)(tabular format) But when I click the submit button,
javascript
when I click the submit button, I want to store it in the text file (.txt)(tabular format)
But when I click the submit button, it is not stored in the text file
How to fix it?
my code
function readSingleFile(evt) {
var f = evt.target.files[0];
if (f) {
var r = new FileReader();
r.onload = function(e) {
var contents = e.target.result;
document.getElementById("outputdiv").innerHTML =contents;
};
r.readAsText(f);
} else {
alert("Failed to load file");
}
}
document.getElementById('readMessages.txt').addEventListener('change', readSingleFile, true);