title: Editable Table in Flask/HTML
body: <p>I am trying to create an excel-like table to update and log things on the go.</p>
  
  <p>I have found this javascript:</p>
  
  <pre><code>function init()
  {
      var tables = document.getElementsByClassName("editabletable");
      var i;
      for (i = 0; i &lt; tables.length; i++)
      {
          makeTableEditable(tables[i]);
      }
  }
  
  function makeTableEditable(table)
  {
      var rows = table.rows;
      var r;
      for (r = 0; r &lt; rows.length; r++)
      {
          var cols = rows[r].cells;
          var c;
          for (c = 0; c &lt; cols.length; c++)
          {
              var cell = cols[c];
              var listener = makeEditListener(table, r, c);
              cell.addEventListener("input", listener, false);
          }
      }
  }
  
  function makeEditListener(table, row, col)
  {
      return function(event)
      {
          var cell = getCellElement(table, row, col);
          var text = cell.innerHTML.replace(/&lt;br&gt;$/, '');
          var items = split(text);
  
          if (items.length === 1)
          {
              // Text is a single element, so do nothing.
              // Without this each keypress resets the focus.
              return;
          }
  
          var i;
          var r = row;
          var c = col;
          for (i = 0; i &lt; items.length &amp;&amp; r &lt; table.rows.length; i++)
          {
              cell = getCellElement(table, r, c);
              cell.innerHTML = items[i]; // doesn't escape HTML
  
              c++;
              if (c === table.rows[r].cells.length)
              {
                  r++;
                  c = 0;
              }
          }
          cell.focus();
      };
  }
  
  function getCellElement(table, row, col)
  {
      // assume each cell contains a div with the text
      return table.rows[row].cells[col].firstChild;
  }
  
  function split(str)
  {
      // use comma and whitespace as delimiters
      return str.split(/,|\s|&lt;br&gt;/);
  }
  
  window.onload = init;
  </code></pre>
  
  <p>And it seems like it will work well in saving and keeping the edits in the table.</p>
  
  <p>The issue is, however, that I am using pycharms and - unfortunately - cannot use a js file within mine.</p>
  
  <p>Is there a way to convert this to Python, or a way to code a table within Python?</p>