0

how to display the rate file to html page this code is scratch

<h2> Rate plan</h2>
        <table class="ratetable" id="myTable" cellpadding="2" cellspacing="2" border="1" onclick="tester()"></table>

function TableCreate(response) {
    var ratetable;

    var counter = 0;


   var res = response.split(",");

    for (var j = 1; j < res.length; j++) {
        ratetable = {
            pesos: res[j++] + " pesos",
            duration: res[j]
        };
        var table = document.getElementById("myTable");
        var row = table.insertRow(counter++);
        var cell1 = row.insertCell(0);
        var cell2 = row.insertCell(1);

        cell1.innerHTML = ratetable.pesos,
        cell2.innerHTML = ratetable.duration
    }
}

file.txt

,2,30 Minutes,5,1 Hour,10,2 Hours,15,3 Hours,20,5 Hours,30,1 Day,40,2 Days,50,3 Days,60,7 Days,100,15 Days,250,30 Days

i want to look like this final output see the img output

  • Change `j++` to `j += 2` to iterate by 2 elements at a time. – Barmar Aug 22 '22 at 15:30
  • Is it for a website? Why would you want to read that input from a file? – user3738870 Aug 22 '22 at 15:41
  • @user3738870 no its local the opi web is dead no rate display i want to read the file manualy not the url vendo machine is dead – John Wick Aug 22 '22 at 16:26
  • This answer tells you how to read a local file: https://stackoverflow.com/a/14446538/3738870. You can update the question once you get that part working. – user3738870 Aug 22 '22 at 16:37
  • @user3738870 here the rate.html can you help me place it the read txt file display to table https://pastebin.com/ZVu3TL1J – John Wick Aug 22 '22 at 17:10

0 Answers0