function generateTable() {    
    var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };  
    function addMonths(numOfMonths, date = new Date()) {
        date.setMonth(date.getMonth() + numOfMonths);

        return date.toLocaleDateString('es-ES', options);
      }
      const params = new URLSearchParams(document.location.search);  
      
      const interestic = parseFloat(params.get("tic")/1200);  
      const interestcv = parseFloat(params.get("tcv")/1200);
      const m = parseFloat(document.querySelector('#months').value);
      localStorage.setItem( 'months', m );
      const k = parseFloat(document.querySelector('#amount').value);
      const k_ic = parseFloat(document.querySelector('#two').value)*k/100;
      const k_cv = parseFloat(document.querySelector('#three').value)*k/100;
      //let currentDate = new Date().toJSON().slice(0, 10);
      //console.log(currentDate)
      //const ccv = parseFloat(document.getElementById("capital_cv").innerHTML);
      //const cic = parseFloat(document.getElementById("capital_ic").innerHTML);
      let ccv = k_cv
      let cic = k_ic
      let capital_c = [cic];
      let cap_c = [cic];
      console.log(cic)
      let capital_g = [ccv];
      let capital_t = [k];
      //let fechas = [currentDate]
      let periodos = [0]
      let fechas = [new Date().toLocaleDateString('es-ES', options)]
      let fecha = [new Date().toLocaleDateString('es-ES', options)]
      let cap_t = [k]
      let cap_g = [ccv]
      let interes_g = [0]
      let int_g=[0]
      let interes_c=[0]
      let int_c=[0]
      let pagop = [0]
      let pago = [0]
      
      for (i = 0; i<m; i++){
      periodos[i+1] = periodos[i] + 1 ;
      fechas[i+1] = addMonths(i +1, new Date());

          }
      console.log(fechas)    
      for (i = 0; i<=m; i++){
      capital_c[i+1] = (capital_c[i]*(1+interestic));
      capital_g[i+1] = capital_g[i] //+ ccv*interestcv;
      interes_g[i+1] = capital_g[i]*interestcv;
      interes_c[i+1] = capital_c[i]*interestic;
      capital_t[i+1] = capital_c[i+1] + capital_g[i+1];
      pagop[i+1] = interes_g[i+1]
          }
      pagop[m] = capital_c[m] + capital_g[m] + interes_g[m]    
      for (i = 0; i<=m; i++){ 
      cap_t[i] = capital_t[i].toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
      cap_g[i] = capital_g[i].toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
      int_g[i] = interes_g[i].toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
      cap_c[i] = capital_c[i].toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
      int_c[i] = interes_c[i].toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
      pago[i] = pagop[i].toFixed(2).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
      //fecha[i] = fechas[i].getUTCDay() + "/" + fechas[i].getUTCMonth()+1+"/"  + fechas[i].getUTCFullYear();
      fecha[i]= fechas[i];
          }
      var headers = ["Periodo", "Inversión Global",
      "Rendimiento Global", "Inversión Compuesta", 
      "Rendimiento Compuesto",  "Saldo Total", "Pago", "Fecha" ];
      var table = document.createElement("TABLE");  //makes a table element for the page
          
      for(var i = 0; i <= m; i++) {
          var row = table.insertRow(i);                       
          row.insertCell(0).innerHTML = periodos[i];
          row.insertCell(1).innerHTML = cap_g[i];
          row.insertCell(2).innerHTML = int_g[i];
          row.insertCell(3).innerHTML = cap_c[i];
          row.insertCell(4).innerHTML = int_c[i];
          row.insertCell(5).innerHTML = cap_t[i];
          row.insertCell(6).innerHTML = pago[i];
          row.insertCell(7).innerHTML = fechas[i];
          
      }
  
      var header = table.createTHead();
      var headerRow = header.insertRow(0);
      for(var i = 0; i < headers.length; i++) {
          headerRow.insertCell(i).innerHTML = headers[i];
      }
  
      document.body.append(table);
      //var myData = [header.innerHTML, row.innerHTML]
      const myData = table
      console.log(myData.innerHTML)
      localStorage.setItem( 'tabla', myData.innerHTML );
      //localStorage.setItem('table', document.getElementById('payment').innerHTML)   
      //document.getElementById("tabla");
      document.getElementById('tabla').innerHTML = myData.innerHTML;

  }