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);
});
});
}