Question

My goal: i need to read txt file using fso - activeX then separate text by ; and put each separated word in select - option. so far i got this but aint working

<script>
    function readAll() {
        var fso = new AcitveXObject("Scripting.FileSystemObject");
        var txtFile = fso.OpenTextFile("kategorije.txt", 1, false, 0);
        var fText = txtFile.ReadAll();
        txtFile.Close();
    }

    var array = fText.split(";");
    var sel = document.getElementById("dropdown2");
    for (var i = 0; i < dropdown2.length; i++) {
        var opt = document.createElement("option");
        opt.innerHTML = fText[i];
        opt.value = fText[i];
        sel.appendChild[opt];
    }
</script>

No correct solution

OTHER TIPS

function readAll() {
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    var txtFile = fso.OpenTextFile("kategorije.txt", 1, false, 0);

    var fText = txtFile.ReadAll();
    txtFile.Close();
    fso = null
    var array = fText.split("\r\n");
    var sel = document.getElementById("dropdown2");
    for (var i = 0; i < array.length; i++) {
        var opt = document.createElement("option");
        opt.innerHTML = array[i];
        opt.value = array[i];
        sel.appendChild(opt);
    }
}

my code works now and it look like this

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top