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

151
Vistas
Comparing against a dynamic value in a JSON

I have the following JSON array:

[ { "Alpha": {"min": "1", "max": "2"} }, { "Beta": {"min": "10", "max": "20"} }]

The plan is to have the user select Alpha or Beta, and then they can select how many units they need.

var selectedUnit = $("#entry_field").val();
$.getJSON("/json-url/", function(data) {
    var a = data[0].Alpha.min;          // This works
    var b = data[0].selectedUnit.min    // This does not work, and I'm not sure why
    var c = data[0].Beta.min;           // This does not work, but I understand why
    var d = data.Alpha.min;             // This does not work, and I'm not sure why
    var e = data.selectedUnit.min;      // This does not work, and is going to be what I need
    if (e > selectedValue) {
        alert("You are below the minimum units");
    }
});

I'm aware there's multiple things preventing me from setting var e correctly, but I'm not sure the best way to go about setting this value.

about 4 years ago · Juan Pablo Isaza
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