I want to pass the data I receive in the parameters of a JS function and print it in PHP:
$autodoc = $fila['AUTODOC'];
$autolin = $fila['AUTOLIN'];
$autofue = $fila['AUTOFUE'];
Through the onclick event I take the parameters to the function
echo "<td>";
echo "<button name='nombre' type='submit' class='btn btn-success' onclick='accion( \"{$autofue}\", \"{$autodoc}\", \"{$autolin}\");'> AUTORIZAR</button>";
echo "</td>";
// JS function
function accion(a, b, c){
alert(a+' '+b+' '+c);
<?php
echo "<p>'{a}'</p>"; // imprimir el parametro que recibo de JS en esta linea
$stid = oci_parse($conn, "DELETE FROM TAB_AUTO
where autofue='IN'
and autodoc='1017951'
and autolin= 1");
oci_execute($stid); ?>
}
</script>
The first thing is that you have to separate the waters. PHP is executed on the server side and JS on the Client side (considering the exceptions)
Knowing this, what I recommend is to do the following.
Deducing, according to your code, that you have selected a record which has the id of something you want to delete, you would have to send this
ID
to a controller in PHP, through AJAX (from javascript)Then in the
controlador.php
So when your controller processes whatever you want to do, it will return a message which will be received by
success
your javascriptwhat you want to do is not normal or not right, also your php does not have any JS value, you can be more specific if the function comes from a form (from a submit button).
Cheers!