0

I have one service which gives me lots of Data from back-end. I have to show that in a table using jquery. I shows every data but unable to show the materialDetails in a selectbox. Could anyone help me on this ?

 $.each(response.data[0].listRawItemDetails, function (i) {
                            $("#received_item > tbody").append("<tr>" +
                                                        "<td>" + '<input type="hidden" name="fabricId'+i+'" value="'+response.data[0].listRawItemDetails[i].fabricId+'">'+ response.data[0].listRawItemDetails[i].fabriceCode + "</td>" +
                                                        "<td>" + '<input type="hidden" name="measurementRange'+i+'" value="'+response.data[0].listRawItemDetails[i].measurementRange+'">'+ response.data[0].listRawItemDetails[i].measurementRange + ' ' +response.data[0].listRawItemDetails[i].measurementType+ "</td>" +
                                                        "<td>" + '<input type="text" name="rate_'+i+'" id="rate_'+i+'" class="form-control rateCheck" value="" placeholder="Per '+response.data[0].listRawItemDetails[i].measurementType+'" style="width: 100px;" required="required">'+"</td>" +
                                                        "<td>" + '<span class="totalAmt'+i+'"></span>' + "</td>" +
                                                        **"<td>" + '<select class="form-control" id="materialDetails'+i+'"><option value="">-Select-</option></select>' + "</td>" +**
                                                    "</tr>");
                    }) //foreach

From response.data[0].listRawItemDetails[i].meterials I'm getting list of materials, I need to show that data, in last table data as a selectbox for each row.

8
  • Please explain your problem more briefly and post your all code that you have done yet. Commented Nov 8, 2019 at 6:08
  • I want to show the details coming from response.data[0].meterials (It's a List) inside #materialDetails select box Commented Nov 8, 2019 at 6:15
  • response.data[0].listRawItemDetails and response.data[0].meterials are not same. Commented Nov 8, 2019 at 6:18
  • Both are different Commented Nov 8, 2019 at 6:18
  • That is what I am trying to say, meterials has the data but you are using listRawItemDetails in the code! Commented Nov 8, 2019 at 6:22

1 Answer 1

1

I added these lines of code it works for me..

$.each(response.data[0].listRawItemDetails, function (i) {
                        $.each(response.data[0].listRawItemDetails[0].meterials, function(index, value) {
                            $('#materialDetails'+i).append('<option value="' + value+ '">' + value+ '</option>');
                        });
                    }); //foreach
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.