Doubt How to perform onChange in two Selects

1

I would like to know how best to perform an onChange in the two selects I have in my form follows the selects:

<div class="row">
  <div class="col-md-12">
    <div class="form-group ${status.error ? has-error : '' }">
      <label for="listaContato" class="control-label"><spring:message
          code="ca_tipo_contato" /></label> <label
        class="listaContato control-label ${status.error ? has-error : ''}">
        <form:errors path="tipoContato" element="label" />
      </label>

      <form:select path="tipoContato" id="listaContato"
        data-placeholder="Contato" cssClass="form-control"
        cssStyle="width:100%;">
        <form:option value=""></form:option>
        <form:options items="${listaContato}"
          itemLabel="tipoContato" itemValue="id" />
      </form:select>
    </div>
  </div>
</div>
<div class="row">
  <div class="col-md-12">
    <div class="form-group ${status.error ? has-error : '' }">
      <label for="listaDescricaoContato" class="control-label"><spring:message
          code="ca_descricao_contato" /></label> <label
        class="listaDescricaoContato control-label ${status.error ? has-error : ''}">
        <form:errors path="tipoDescricaoContato" element="label" />
      </label>

      <form:select path="tipoDescricaoContato"
        id="tipoDescricaoContato"
        data-placeholder="Descrição Contato"
        cssClass="form-control" cssStyle="width:100%;">
        <form:option value=""></form:option>
        <form:options items="${listaDescricaoContato}"
          itemLabel="tipoDescricaoContato"
          itemValue="id" />
      </form:select>
    </div>
  </div>

TypeDescription depends on the TypeContact as you would to perform this onChange.

    
asked by anonymous 12.12.2017 / 19:57

1 answer

0

Good staff thanks but I managed to resolve it as follows:

   $( "#nomeSubStatusAnomalia" ).prop( "disabled", true );

            $("#nomeStatus").change(function () {
                    var StatusAnomalia = $("#nomeStatus").val();
                jQuery.ajax({
                        contentType : 'application/json; charset=utf-8',
                        type : 'GET',
                        url : '/cct/anomalia/changeSubStatusAnomalia/'+ StatusAnomalia,

                            beforeSend : function(xhr) {

                                xhr.setRequestHeader("Accept", "application/json");
                                xhr.setRequestHeader("Content-Type", "application/json");
                                xhr.setRequestHeader(header, token);
                            },

                            success : function(response) {

                                console.log(response);


                                $.each(response, function(index, value){

                                    $("#nomeSubStatusAnomalia").append(

                                         '<option value='+ value.nomeSubStatusAnomalia +'>'+ value.nomeSubStatusAnomalia +'</option>'

                                    );

                               });

                            $( "#nomeSubStatusAnomalia" ).prop( "disabled", false );

                        },
                        error : function(response, textStatus, errorThrown) {

                        }
                });

        });

I mounted this ajax to meet the needs of my form.

    
15.12.2017 / 20:05