jQuery(document).ready(function(){
  $(".finder-element").change(function(){
    $.getJSON("/franchise/updateFinderModule?industry=" + $('#industry').val() + "&investment=" + $('#investment').val(),
     {nt: Math.floor(Math.random()*1000001)},
     function(j){
//      $(".finder-element").attr("disabled","disabled");
        var options = '';

        for (var i = 0; i < j['industry'].length; i++) {
            if(j['industry'][i].selected)
            {
            selectedId = i +1;
            }
            options += '<option class="' + j['industry'][i].class + '" value="' + j['industry'][i].optionValue + '">' + j['industry'][i].optionDisplay + '</option>';
        }
        
        $("select#industry").html(options);
        $("select#industry option:nth-child(" + selectedId + ")").attr('selected', 'selected');
        var options = '';
        for (var i = 0; i < j['investment'].length; i++) {
            if(j['investment'][i].selected)
            {
                selectedId = i +1;
            }
            options += '<option value="' + j['investment'][i].optionValue + '">' + j['investment'][i].optionDisplay + '</option>';
        }
        $("select#investment").html(options);
        $("select#investment option:nth-child(" + selectedId + ")").attr('selected', 'selected');
        
//      $(".finder-element").removeAttr("disabled")

    })
  });
;
 })