0

I've created a table row using jquery, and I want to fill some data to it. When I was checking with console.log the data was appropriate, but not filled the column.

How can I fill the column from it ?

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

1 Answer 1

1

I found that the following coding is working properly. if the javascript changed to

$('#service\\['+id+'\\]').first().val(element.service_name);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.