1

Here is my code snippet

for (var k = 0; k < link_list.length; k++) {
    var service_list = document.getElementsByName("service_info");
    service_list = $(service_list).children("div[name=service_info_element]");
    for (var i = 0; i < service_list.length; i++){
        var service_info = {};
        service_info["service_name"] = $(service_list[i]).find("select[name=service_name]").val();
        service_info["service_type"] = $(service_list[i]).find("input[name=service_type]").val();

    }

How can I get $(service_list[i]).find("select[name=service_name]").val() and $(service_list[i]).find("input[name=service_type]").val(); for each link_list[k] inside the second loop. I mean I need something like link_list[k].service_list[i].find("select[name=service_name]").val()

3
  • How about $.each with $(this) ? Commented Apr 28, 2016 at 7:50
  • have you tried .each()?? Commented Apr 28, 2016 at 7:54
  • I faced some problems with .each() to get my desired result. Anyway I have solved it using the following line: var service_list = $(link_list[k]).find("div[name=service_info_element]"); thanks for your suggestions :) Commented Apr 28, 2016 at 14:21

2 Answers 2

1

You can try this it'll work $('service_list[i]').find('select[name=service_name]').filter([0,3,4]).anything();

Sign up to request clarification or add additional context in comments.

Comments

0

Try the following:

link_list[k].service_list[i].find("select[name=service_name]").each(function(i, element){
    var val = $(this).val(); // or element.val()
});

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.