Send selected value to an Insert.php file

Asked

Viewed 26 times

0

Good afternoon!

I wonder if there is a way to perform an Insert in the database from a selection in a Dropdown.

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

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

From now on, thank you very much.

  • have you tried using <select> ? send the form with ajax and get the value via $_POST?

1 answer

0

Hello You need the file containing the form make a call to a js that can create to receive the form data and to run.

    <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 gets the information by get and handles insertion

Browser other questions tagged

You are not signed in. Login or sign up in order to post.