1
I have a question regarding recovering the information from an html table and saving it in the database using Windows.
This part of the application consists of storing in a table user_exame information related to exams that this user should perform.
In the table I store the user_id, exame_id, dt_utlimo_exame, dt_proximo_exame
I’m populating the html table with following code:
eventsForm: function(){
jQuery('#btn-adicionar-exame').click(function(){
moment.locale('pt-br');
var id = jQuery('#exame').find('option:selected').val();
var exame = jQuery('#exame').find('option:selected').text();
var periodical = jQuery('#periodical').find('option:selected').val();
var periodicalText = jQuery('#periodical').find('option:selected').text();
var ultimoExame = jQuery('#dtUltimoExame').val();
var newRow = $("<tr>");
var cols = "";
var proximoExame = '';
//Define a proxima data do exame
proximoExame = moment(ultimoExame, "DD/MM/YYYY").add(periodical, 'months');
cols += '<td>' + id + '</td>';
cols += '<td>' + exame + '</td>';
cols += '<td>' + periodicalText + '</td>';
cols += '<td>' + ultimoExame + '</td>';
cols += '<td>' + moment(proximoExame, "DD/MM/YYYY").calendar() + '</td>';
cols += '<td>';
cols += '<button type="button" class="btn btn-link " id="btn-delet" onclick="employee.removeTableRow(this)"><i class="fa fa-trash fa-1x color-red"></i></button>';
cols += '</td>';
newRow.append(cols);
/Adicionando a row a tabela
jQuery("#table-list-exames").append(newRow);
//Limpando os campos
jQuery('#exame').val("").change();
jQuery('#periodical').val("").change();
jQuery('#dtUltimoExame').val('');
});
},
My question is: how to recover each row of the table and store in the bank using Laravel?
I know that in javascript could do something like:
tableExames.find('tr').each(function (i) {...}
but how to do this in the Laravel controller?
I only realized later that your question is about the Laravel’s controllers part. Sorry... but once you handle the data, the backend part isn’t crazy, right?
– Daniel
No problem. I still can’t find a solution. I thought about calling a javascript function by the onclick event instead of giving a Submit in the form. In this function I would retrieve table information and store it in an object. Then I would call the controller method by passing this object. Well, I don’t know if it would work or if it would be the right way. Chagando at home I will try to do this.
– L.B.O
So, this solution I described would do the part of sending the data to PHP using
Ajax
, I just didn’t put the part of sending to the server using Javascript, because I thought it would be a lot. Once you send using thejQuery.post
no error, will get there as if it were a normal PHP array, staying inside the $_POST variable. The part of Laravel that I don’t know because I never used this framework.– Daniel
Guys, I still can’t solve my problem. Could you help me?
– L.B.O
What is going on? You have to give the details, man, we’re not telepathic :) Anyway, better ask a new question, unless you’re still in the same trouble.
– Daniel