嵌套数据列表

时间:2017-03-04 11:47:13

标签: javascript jquery javascript-events jquery-selectors

如何为datalist couple编写选择器。当我点击路由datalist时,person_name datalist显示连接值。但它适用于拳头夫妇。如何为每一对datalist编写事件。

   $(".route").on("input", function () {
                $.getJSON('getpersonnamebyroutenumber.jsp', {route_number: $(this).val()}, function (data) {
                    $.each(data, function (index, element) {
                        $('.person_namelist').append("<option value='" + element.person_name + "'>");
                        $('.person_name').val(element.person_name);                            
                });
            });


    <div id="input_fields_wrap" class="input_fields_wrap">
                    <button class="add_field_button">Add More Fields</button>
                    <div>                  
                        <input  type="text" id="route" list="routelist" class="route" name="mytext[]" autocomplete="off"><datalist id="routelist" class="routelist" ></datalist>                
                        <input  type="text" id="person_name" list="person_namelist" class="person_name" name="mytext2[]" autocomplete="off"><datalist id="person_namelist" class="person_namelist"></datalist>
                    </div>
                </div> 

0 个答案:

没有答案