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

193
Views
How to set one State with few value of inputs

i would like to know how can i set one state with few inputs value for the example this is the state

const [userBirthday, setUserBirthday] = useState('')

there are 3 inputs, i want to get e.target.value from each one and conbain them in the state

something like that **I know the syntax actually not good but it is only to simplify my question

      <input type="text"
           placeholder='Day'
           onChange={(e) => {
              setUserBirthday(userBirthday += e.target.value)
           }}
      />
      <input type="text"
           placeholder='Day'
           onChange={(e) => {
              setUserBirthday(userBirthday += e.target.value)
           }}
      />
      <input type="text"
           placeholder='Day'
           onChange={(e) => {
              setUserBirthday(userBirthday += e.target.value)
           }}
      />   

`

console.log(userBirthday) == Result: 12 September 2020

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This function will do the job, you need to add the handleChange method to all the input field's prop "onChange" and you need to add the name prop to all the input fields, I added input1 for the demo.

  const handleChange = (e) => {
    const data = { ...userBirthday };
    data[e.currentTarget.name] = e.currentTarget.value;
    setUserBirthday(data);
  };



 <input type="text"
           name="input1"
           placeholder='Day'
           onChange={handleChange}
      /> 
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!