0
jqueryを使用してテーブル行を作成しましたが、データを入力したいと思います。 console.log
で確認したところ、データは適切であったものの、列は埋められませんでした。jqueryテーブルへのデータの挿入
どのようにして列を記入できますか?
function getCorporateService(id){
//create new row
$br = "<tr id='item'>";
$br += "<td> <input class='input-small' type='text' id='order_identifier' name='order_identifier' readonly></td>";
$br += "<td><input class='input-small' type='text' id='service["+id+"]' name='service["+id+"]' readonly></td>";
$br += "<td><select id='order_type["+id+"]' name='order_type["+id+"]'> <option> - </option> <option value='add'>Add</option> <option value='change'>Change</option> <option value='cancel'>Cancel</option> </select></td>";
$br += "<td><input class='input-small' type='text' id='select_plan["+id+"]' name='select_plan["+id+"]'></td>";
$br += "<td><input class='input-mini' type='text' id='qty["+id+"]' name='qty["+id+"]'></td>";
$br += "<td><input class='input-small' type='text' id='unit_price["+id+"]' name='unit_price["+id+"]'></td>";
$br += "<td><input class='input-small' type='text' id='total_price["+id+"]' name='total_price["+id+"]'></td>";
$br += "<td><input class='input-small' type='text' id='notes["+id+"]' name='notes["+id+"]'></td>";
$br += "</tr>";
$(".corporatesvc").append($br);
//get data and parsing to column
$.get("{{ url('salesorder/service')}}/"+id, function(data){
console.log(id);
console.log(data);
$.each(data, function (index, element){
$('#service['+id+']').val(element.service_name);
});
});
}