0

So I've been searching for a simply way to read a file and store each string line by line as you go through the file. I know how to do it in Java where you have a file variable and just do file.nextLine() to proceed to the next line till you hit the end.

Was wondering if there is a simple way to just do that. I have a HTML file that has a button with an input tag that grabs a file, but I don't know the syntax to store the file variable in JavaScript and do a loop going line by line and storing each line in different variables.

Thanks for your time and for the help in advance.

<button id="list">List All Recipes</button>
<button id="add">Add Recipe</button>
<input id="inputFile" type="file" style="display: none;" />
    <button id="remove">Remove Recipe</button>
    <button id="update">Update Recipe</button>


<script>
    //variable declaration
    var recipeList = [];


    //jQuery for button click event
    $('#add').on('click', function() {
        $('#inputFile').trigger('click');
    });
</script>
6

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.