Save form "Registration of Presence" - Multiple Radios Inputs

Asked

Viewed 253 times

0

Hey, guys, all right?

I am developing a system to register the presence of academics of an educational institution, the form data (Course, disciplines and students) I am searching for web service of their education system, see the image below how it was:

inserir a descrição da imagem aqui

To save the first three inputs is quiet, my problem is that I could not think of how to save this list of INPUTS RADIO inside the table, because the NAMES of the inputs I filled dynamically with the students' Ids, follows the example below:

STUDENT 1:

<input type="radio" name="5334" value="1" /> <!--(Esse representa o "Presente")-->
<input type="radio" name="5334" value="0" /> <!--(Esse representa o "Ausente")-->

STUDENT 2:

<input type="radio" name="5452" value="1" /> <!--(Esse representa o "Presente")-->
<input type="radio" name="5452" value="0" /> <!--(Esse representa o "Ausente")-->

Please if anyone can give me a light I am very grateful.

NOTE: Use PHP 7, apache 2.4 and Laravel 5.4 as a framework.

  • I don’t know if I understood your question right, but you could go through all the elements of the form with the .each of jQuery: $("form").each(function(){&#xA; $(this).find(':input')&#xA;}); and, based on name of the element, make your INSERT/UPDATE

1 answer

-1

You need to pass the data in array format, not sure how to explain but you can create an input with the same name and save the data in php later through a foreach

In html:

<input type="radio" name="ausente[][id_do_aluno]" value="1" />
<input type="radio" name="presente[][id_do_aluno]" value="0" /> 

In PHP:

$valores = $_POST['ausente'];

foreach($valores as $valor){
   //aqui você terá uma array com os valores, use-os como desejado
   var_dump($valor);
}
  • Thank you very much friend, your idea fit like a glove, vlw by exemplifying php html, I managed to solve my problem, hugs.

  • Arrange, Hugs :)

Browser other questions tagged

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