JSFiddle - React, Tailwind, and code Playground

by Владимир Коротенко

HTML

<html>

  <body>
    <table id="able" border="1" cellpadding="5" cellspacing="2">
      <tr>
        <th> Номер </th>
        <th> Товар </th>
        <th> Количество </th>
        <th> Цена </th>
        <th> Сумма </th>
      </tr>      
    </table>
    <button  id="sb">Start</button>
  </body>

</html>

JavaScript

var button = document.getElementById('sb')
button.onclick = sendReq;

var htReq = ('v' == '\v') ? new ActiveXObject('MicrosoftXMLHTTP') : new XMLHttpRequest();

function sendReq() {

  htReq.open('get', 'my.txt');
  htReq.onreadystatechange = getReq;
  htReq.send(null);

}


function getReq() {
  if (htReq.readyState === 4) {

    var emuldate = "1122\tCamera-11\thd\t1\t1300\r\n1123\tCamera-12\thd\t2\t1400";

    var lines = emuldate.split("\n");
    var table = document.getElementById('able');

    for (var i = 0; i < lines.length; i++) {
      var nRow = table.insertRow(1);
      var nCell0 = nRow.insertCell(0);
      var nCell1 = nRow.insertCell(1);
      var nCell2 = nRow.insertCell(2);
      var nCell3 = nRow.insertCell(3);
      var nCell4 = nRow.insertCell(4);
      var cont = lines[i].split('\t');

      nCell0.innerHTML = cont[0];
      nCell1.innerHTML = cont[1];
      nCell2.innerHTML = cont[2];
      nCell3.innerHTML = cont[3];
      nCell4.innerHTML = cont[4];
    }
  }
}