Send selected value to an insert.php file

0

Good afternoon!

I would like to know if there is a way to perform an insert into the database from a selection in a DropDown.

This selection would be sent to a file (example) "insert.php", in which you would insert into the table, and this would be done with Ajax.

I tried to look for some alternatives, however, I only found methods using with submit, and thus executing functions with the Insert command.

Thank you in advance.

    
asked by anonymous 19.11.2016 / 19:52

1 answer

0

Hello Need that in the file that contains the form make a call to a js that you can create to receive form data and seri -ize.

    <src="script.js"></script>


<form id="Form" action="" method="GET" class="form-horizontal">
 ... campos do formulário
</form>

js file

jQuery(document).ready(function(){
jQuery('#Form').submit(function(){
    carregando(1);
    // seria liza os dados do formulário            
    var dados = jQuery( this ).serialize();
    //var dados = new FormData(this);
    jQuery.ajax({
        type: "GET",
        url: "arquivo.php",
        data: dados,
        success: function(data) {
            carregando(0);
             //msg = JSON.parse(data);
             //alert (msg);
             $('#ret').html(data);
        }
    });
    return false;
});

});

And in the PHP file it gets the information by get and treats the insert

    
03.06.2017 / 15:22