Create a filter from a value in a field

0

Good morning

I've created two fields for selection. And one of them has a list of values. When I select the value, in another field, which will also have a list, I need only the corresponding values to appear.

In the example below, the code on the side lists the description on the right side. That way when I select the code 411075145 I want the other selection field to look like the Agreement, Deposit and INSS Tab descriptions

  

411075145 - Agreement

     

411075145 - Deposit

     

411075145 - INSS Guide

Below is the code:

function  CarregarRelativo() {
    $('#Relativo').empty();
    AddDropDownItem('Relativo', '', '');

    var 
    var data = GetListItems('02FC4BE9-B056-486D-A9C6-3743DF5F9257',"?$orderby=Title");

    if (data != null) {
        data.forEach(function(item) {
            AddDropDownItem('Relativo', item.DescricaoContaContabil,item.DescricaoContaContabil);
        });
    }
}
    
asked by anonymous 30.01.2018 / 11:40

1 answer

0

For your code you can not help because I do not know what you are doing in AddDropDownItem.

But follow an example that gets the code from one and adds the description to another.

See if it suits you.

$(document).ready(function(){
		var ListCodigosDescricao = [];
    ListCodigosDescricao.push({Codigo: 12345151, Descricao:'Formulario 1'});
    ListCodigosDescricao.push({Codigo: 84574848, Descricao:'Formulario 2'});
    ListCodigosDescricao.push({Codigo: 45487548, Descricao:'Formulario 3'});
    
    var selectCodigos = $('#selectCodigos');
    
    $.each(ListCodigosDescricao, function(i, el){
    	selectCodigos.append('<option value="' + i + '">' + el.Codigo + '</option>');
    });
    
  	$("#selectCodigos").change(function(){
    	var itemDaLista = ListCodigosDescricao[this.value];
        $('#selectDescricao').append('<option value="">' + itemDaLista.Descricao + '</option>');
  	});
  });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<label>Selecione um Código:</label>
<select id='selectCodigos'>
  <option></option>
</select>
<br/>
<label>Selecione uma Descrição:</label>
<select id='selectDescricao'>
  <option></option>
</select>
    
30.01.2018 / 14:22