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

160
Views
How to use onChange in multi-select react form?

In case of multi-select , can someone help me with the onChange function ?

What can I pass inside updateFormState( ) to make the code work. Thanks.

const formState = {
 fruits: "",
}; 


function updateFormState(key, value) {
  formState[key] = value;
}

const [fruits] = useState([]);

      <Form.Label>fruits</Form.Label>
          <MultiSelect
           options={[
            { label: "Grapes ๐Ÿ‡", value: "grapes" },
            { label: "Mango ๐Ÿฅญ", value: "mango" },
            { label: "Strawberry ๐Ÿ“", value: "strawberry", disabled: true },
            ]}
           id="fruits" 
           labelledBy="Select"
           value={fruits}
           onChange={(e) => updateFormState( )}
          />
         </Form.Group>

about 4 years ago ยท Juan Pablo Isaza
1 answers
Answer question

0

hi try this i hope it usefull


  const [fruits, setFruits] = useState();
  console.log("fruits",fruits);

  return (
    <div>
      <select onChange={(e) => setFruits(e.target.value)} value={fruits}>
        <option value='' selected disabled hidden>
          select a fruits
        </option>
        <option value='apple'>apple</option>
        <option value='banana'>banana</option>
        <option value='orange'>orange</option>
      </select>
    </div>
  );
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!