React Js - Select, Why I'm Getting Double Values Printed And Stored In The Database
Okay I have a question why when someone clicks on multiple selects answers it does store all the value instead of only storing the last value ? So let's say I have a select with 2
Solution 1:
The problem is in onChange = {(e) => setidType1([...idType1, e.target.value])
.
Every time the value in the select
changes, you add the selected value to idType1
. Given that this is a dropdown, you'll typically want to replace the existing value of idType1
with the newly selected value.
So:
onChange = { (e) => setidType1(e.target.value) }
Post a Comment for "React Js - Select, Why I'm Getting Double Values Printed And Stored In The Database"