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

159
Visualizações
Set default value for select if `select` is inserted

I have a form with fields. If RiskType field is ILI and at the same time 'Limit Type' field is I or Y, then The Settlement drop down list is inserted my question is how to make the netSettlement variable set value the first option in select. If this form has been inserted in the DOM (logically, if the form is not inserted, the value is not set)

    {(riskType === 'ILI' && (limitType === 'Y' || limitType === 'I')) &&
      <Form.Row>
        <Form.Group controlId='formGridNetSettlement'>
          <Form.Label>Settlement</Form.Label>
          <Form.Control name='netSettlement' as='select' value={netSettlement}
                        onChange={e => {setNetSettlement(e.currentTarget.value)} }
                        required={!isSearch}>
            <option>True</option>
            <option>False</option>
          </Form.Control>
        </Form.Group>
      </Form.Row>
    }
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

You'll want to add the selected attribute to the option that you want pre-selected when the form is loaded:

<option selected value="true">True</option>
<option value="false">False</option>

Also, you will want to set the value attribute with the actual value you want to submit.

about 4 years ago · Juan Pablo Isaza Relatório

0

You do not have values in options at all. If you're receiving Boolean value for netSettlement try this

{
  riskType === "ILI" && (limitType === "Y" || limitType === "I") && (
    <Form.Row>
      <Form.Group controlId="formGridNetSettlement">
        <Form.Label>Settlement</Form.Label>
        <Form.Control
          name="netSettlement"
          as="select"
          value={netSettlement.toString()}
          onChange={(e) => {
            setNetSettlement(e.currentTarget.value);
          }}
          required={!isSearch}
        >
          <option value="true">True</option>
          <option value="false">False</option>
        </Form.Control>
      </Form.Group>
    </Form.Row>
  );
}

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