Just wanted to know if any of you had any code (JQuery, AJAX, etc) to add a new row to a table that has some dropdown lists in some columns... I was able to add a new row by adding some javascript and jquery, but for some reason (it was working before, but suddenly stopped and I cannot recall the last changes I made to be honest) it's not working anymore. First, I made PHP functions to retrieve the contents for the dropdowns from a DB. Then I added the HTML code in a java script function ("Addnewrow()") to add the new rows and include the dropdowns in specific columns. Thing is, rows are only added when I remove the lines in the "Addnewrow()" function that contains the PHP function ("creaLista"). I have tried changing the Jquery versions, removing all bootstrap files and so, but nothing works. I also tried different combinations in those lines of single and double quotes. I also removed the non-essential code, such as the "Render" section for the selectpicker
Here's the javascript section:
function addnewrow()
{
$('.selectpicker').selectpicker('render');
var n = ($('.detail tr').length-0)+1;
var tr = "<tr>" +
'<td class="no">' + n + '</td>'+
"<td><?php creaLista('mrditemid[]',3,'SPARES_ID','SPARES_BRIEFDESC',$query2, $m);?></td>"+
"<td><?php creaLista('mrdunits[]',4,'UNIT_ID','UNIT_DESC',$query2, $m);?></td>"+
'<td><input type="text" class="form-control mrdquantity" name="mrdquantity[]"></td>'+
'<td><input type="text" class="form-control mrdremarks" name="mrdremarks[]"></td>'+
'<td><button class="btnDelete btn btn-danger">-</td>'+
'</tr>';
$('.detail').append(tr);
}
I may add that the first row is generated automaticaly in HTML, also calling the same function "crealista" and it works fine. Now, when I click on the button that triggers the "Addrow()" function it simply does nothing, and when I remove the lines containing the "Crealista" function it does work, so it has to do with how the var "tr" is being read, I believe...
Thanks in advance for any insights on this!