I have a form with four <input type='submit'/> buttons and action='updateEstado.php'. Also, I have some jQuery code that launches when I click a button.
<!-- CHANGE STATUS MODAL MENU --> <div class="modal fade" id="change" tabindex="-1" role="dialog" aria-labelledby="change" aria-hidden="true"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span></button> <h4 class="modal-title custom_align" id="Heading">CANVIAR ESTAT</h3> </div> <form action="updateEstado.php" method="post"> <div class="modal-body"> <div class=" text-center"> <div class="container-fluid"> <div class="row"> <div class="col-md-12 text-center"> <input type="submit" id="cambiarestado" class="btn btn-modal-estado" style="background-color:YellowGreen; color:white;" value="ACTIVAT"> </div> </div> <div class="row"> <div class="col-md-12 text-center"> <input type="submit" id="cambiarestado" class="btn btn-modal-estado" style="background-color:Tomato; color:white;" value="PENDENT MIQUEL ALIMENTACIÓ"> </div> </div> <div class="row "> <div class="col-md-12 text center"> <input type="submit" id="cambiarestado" class="btn btn-modal-estado" style="background-color:SkyBlue; color:white;" value="PENDENT ADDCOM"> </div> </div> <div class="row"> <div class="col-md-12 text center"> <input type="submit" id="cambiarestado" class="btn btn-modal-estado" style="background-color:Gray; color:white;" value="DESACTIVAT"> </div> </div> <div class="row"> <h5 id='codigosSeleccionados'></h5> </div> </div> </div> </div> </form> </div> </div> </div> </div> <script> $('#cambiarestado').click(function(){ event.preventDefault(); // Get the value of the input fields var inputvalue = $(this).attr("value"); // Send Ajax request to updateEstado.php, with value set as 'input' in the POST data $.post("updateEstado.php", {estado: "DESACTIVAT", codigo: "38"}); alert(inputvalue); }); </script> I have updated the jquery code with this new line: event.preventDefault();
Now when I launch the updateEstado.php the console show this message:
If I delete this line: $.post("updateEstado2.php", {estado: "DESACTIVAT", codigo: "38"});
The show message disappear. It's clear this is the problem. The solution¿? I do not...

idnames. Instead useclassas the trigger.