How to pass a javascript variable to a function in php?

0

Some of the variables already exist and have content in php but others I am capturing with javascript and I need to send all that to another php file.

  include("functions.php");

  <?php
    $id_documento = "1";
    $fecha_final = "2018-09-08"
  ?>

  <html>
    <body>
     <input type="text" id="fecha_inicio">
     <input type="button" onclick="updateFecha()">
     <div id="render"></div>
    </body>
  </html>

  <script>
    function updateFecha(){
      var fecha_inicio = document.getElementById("fecha_inicio").value;
      var inner = '<?php load_izquierda($id_documento,'fecha_inicio',$fecha_final); ?>';
      document.getElementById("render").innerHTML = inner;
    }
  </script>

php file functions.php

<?php
  function load_izquierda($id_documento,$fecha_inicio,$fecha_final){
    $detalle = "<div>Numero documento : $id_documento</div>
                <div>Fecha Inicio : $fecha_inicio</div>
                <div>fecha Final : $fecha_final</div>";
    $detalle = str_replace(array("\r","\n","\t"),array("","",""),$detalle);
    return $detalle;
  }
?>
    
asked by David Espinal 21.02.2018 в 18:05
source

0 answers