0

I want it to be the same file every time rather than having to input a filename or choosing a file when the page opens. My code below requires me to choose a file, I would like it to just put the data in an array each time the page is refreshed.

$(document).ready(function () {
    $("#filename").change(function (e) {
        var reader = new FileReader();

        reader.onload = function (e) {

            var csvVal = e.target.result.split("\n"); //lines
            var csvValue = csvVal[0].split(","); //each word
            var word = "";
            var allText = "";

            for (var n = 0; n < csvVal.length - 1; n++) {
                for (var i = -1; i < csvValue.length; i++) {

                    var word = (n + 1) + " " + csvVal[n] + " " + "<br>";
                }
                var allText = allText + word;

                $("#cardData").html(allText);
            }
        };
        reader.readAsText(e.target.files.item(0));
        return false;
    });

Any help would be appreciated, thanks!

2

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.