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

241
Visualizações
HTML option value post over Boolean instead of String

I have a simple HTML select dropwdown in which the user can change between the following values

<select id="changeIsActive">
    <option value = true>Active</option>
    <option value = false>Inactive</option>
    <option>All</option>
</select>

I then have an event that binds to ^ that "converts" the String values into actual Booleans. And the Booleans then get passed to a Mongo Query Object for the Server to filter on.

'change #changeIsActive'(e, template) {           
          let retVal;
          switch (e.target.value) {
            case "true":
                retVal = true;
                break;
            case "false":
                retVal = false;
                break;
            case "All":
                retVal = null;
            default:
                break;
        }
    }

Is there a better way of converting the String literal of "true" and "false" to their Boolean values? Thanks

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

'change #changeIsActive'(e, template) {           
const obj = {
    'true':true,
    'false':false,
    'All':null
}

const retVal  = obj[e.target.value] 
}
about 4 years ago · Juan Pablo Isaza Relatório
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