How can I insert correctly with jquery html code next to php in a modal?

0

I want to insert within a modal a textfield with a button that picks up the value of this textfield when I click on the button, for this I am using jquery and I am inserting the html next to a if(isset($_POST["boton"])) in php to perform an action when the button is pressed. in this way:

 $(document).ready(function(){
 $('#ModifCo').click(function(){
     $('#inyeccion').html('<form method="post">'+
                     '<table>'+
                     '<tr>'+
                        '<td>Comision de la AFP &nbsp</td>'+
                     '<td><input type="number" name="txtComisionAFP"></td>'+
                     '</tr>'+
                     '<td><br><input type="submit" name="boton" id="boton" value="Insertar Datos" class=" btn btn-default"> <br> </td>'+
                     '</form>'+
                     '<?php'+
                        'if(isset($_POST["boton"]))'+ 
                        '$ComisionAFP= $_POST["txtComisionAFP"];'+
                        'require_once "AFP.php";'+
                        'require_once "UpdateDB.php";'+
                        '$afp= new AFP("","","",$ComisionAFP);'+
                        '$op= new Update();'+
                        '$op->UpdateComision($afp);'+ 
                     '</table>')
});

The problem arises here $op->UpdateComision($afp); since jquery does not detect the arrow - > and he sends it to me only as a text.

Well some suggestion. PS: I'm learning

    
asked by Mtac 13.12.2017 в 05:20
source

1 answer

1

As you have been told, PHP runs on the server side and jquery on the client side, so the quick answer to your question is that you can not.

With what now my advice, or as I would do.

On the page where you have the modal, you should create the code Jquery , which does the thing to collect the value of textfield , and somehow you can launch a form to use the part you have of if(isset($_POST["boton"])) .

I know that the answer is a bit theoretical, but with the code you have put, it is what I can tell you

    
answered by 13.12.2017 в 08:26