Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

159
Vistas
JQuery Radio Button checked and change event

In my asp.MVC application there are two radio buttons and one combo box.

Someone clicked to radiobutton 1, combo box load some data. If clicked to the radiobutton 2, loads different data to the combo box. Script was written using the ajax.

The code is working fine when User click changed the radio buttons. But for some users I have hidden the radiobutton 2. So for them only radiobutton 1 is visible, But at that situation, there is no data loaded to the combo box.

Want to know that also, If there is radiobutton checked when load the view, need to get related data to the combobox.

$(function() {

  $('[id*=ddlTopEmployees]').select2().next().hide();
  $('[id*=Approve_Type]').change(function() {
    setDropDownProductsA($(this).val())
  });
});

function setDropDownProductsA(xVal) {
  try {

    $("#ddlEmployees").empty().trigger("change")
    $.ajax({
      url: '../FindProductTypes',
      type: 'POST',
      dataType: 'json',
      cache: false,
      async: false,
      data: {
        AppLvlId: xVal
      },
      success: function(data) {
        if (data.Success == true) {

          $("#ddlEmployees").select2({
            width: '100%',
            data: JSON.parse(data.items)
          });
        }
      }
    });
  } catch (err) {
    console.log(err.message)
  }
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

use click instead of change

$('[id*=Approve_Type]').click(function() {
    setDropDownProductsA($(this).val())
  });
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda