pass an id and a php name to javascript and return it

0

in php I take an id and a name from my database in mysql and show each name in a checkbox. The problem is that I need to mark several and give a button to delete them and for that I show in javascript a message confirm for security. To the message confirm I pass the names but I also need to pass the id since when I go back to php I need the id to carry out another query and delete the ones I have marked.
In the php:

echo "<form name=form method=POST action=principal.php?orden=desasignar>";
                    //Recorro la matriz para sacar el valor de todos que es el nombre
                    for($i=1;$i<=count($resultsetAsignado);$i++){
                        echo "<td><input type=checkbox name='clientes' value='".$resultsetAsignado[$i][1]."' id='idDelCliente'>".$resultsetAsignado[$i][1]."</td>";
                        //mandamos los id_de los clientes
                        echo "<input type=hidden name='id' value=".$resultsetAsignado[$i][0]." >";
                        echo "</tr>";
                    }
                echo "</table>";
                //boton
                echo "<input type=button name=boton value='Desasignar' onClick='confirmacion();'>";
                echo "</form>";

In javascript

    function confirmacion(){
       //Realizo el confirm y cojo los nombres y los muestro en el confirm
      //y despues lo mando con submit
      document.form.submit();   
    }

In the 0 I keep the id and in the 1 the name.

Any ideas? If you do not understand something tell me

    
asked by play 23.03.2018 в 17:35
source

1 answer

-1

I already put the brackets but I gave an error in javascript when picking up the data and that's why I removed them. The message is sent but I have not put it, because that did not give me problems but what I do is take all the marked and show them and when I accept I do the submit and if not canceled. The problem is to take the id for once marked and shown the names in the confirm to be able to send the id to the php to make the consultation of borado of the marked ones. I will try ajax but I do not have much idea.

    
answered by 25.03.2018 в 13:02