-1

i am not able to get the value from drop list the value that i am getting are wrong, they are reverse if i click complete it will show incomplete in console and vice verse

const [status, setStatus] = useState("");
  const handleChange = (e) => {
    setStatus(e.target.value);
    console.log(status);

<select className="formList" onChange={handleChange}>
          <option value="incomplete">Incomplete</option>
          <option value="complete">Complete</option>
        </select>
  };

i am expecting to get correct values

Mohit Rakh
  • 25
  • 2

1 Answers1

-1

Try this

const [status,setStatus]=useState("");

const handleChange = (e) => {
setStatus(e.target.value);
};

useEffect(() => {
console.log(status);
}, [status]);

return (
<select className="formList" 
onChange={handleChange}>
<option value="incomplete">
Incomplete</option>
<option 
value="complete">Complete</option>
</select>
);
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Apr 29 '23 at 10:22