I am new to javascript and want to load the file without having to click on the load file button
I am using the following script and I want the text to be loaded aut
Try adding the onchange attribute, this will call functions when changes have been made to that input.
Demo
function loadFileAsText(){
var fileToLoad = document.getElementById("fileToLoad").files[0];
var fileReader = new FileReader();
fileReader.onload = function(fileLoadedEvent){
document.getElementById("inputTextToSave").value = fileLoadedEvent.target.result;
};
fileReader.readAsText(fileToLoad, "UTF-8");
}
Select a File to Load:
If you have any questions about the above source code please leave a comment below and I will get back to you as soon as possible.
I hope this helps. Happy coding!