Use JQUERY/JSON to auto fill select dropdown boxes

前端 未结 2 949
南笙
南笙 2021-01-16 20:20

OK I spent spent a lot of time looking over examples but can\'t find one which helps me enough for my situation. I have a JSON file, simplified for this example:

<         


        
2条回答
  •  误落风尘
    2021-01-16 20:55

    This should do the trick.

    $.each(data.Company, function(key, val) {
        $select.append('');
    });
    
    
    
    $("#job").change(function(e) {
        $select2.empty();
        $index = $(this).children(':selected').attr('id');
            for (var k in data.Company[$index].Name) {
                $select2.append('');
            }
    });
    

提交回复
热议问题