Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

158
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!