Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

152
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda