I'm trying to get the selected value of the dropdown using React Js.
It is giving the values but it's giving the wrong values
Please find my code below.
<select
name="category-select-1"
class="form-select category-select"
id="category-select-1"
value={eventCategory}
onChange={handleEventCategory}>
<option value={"default"}>Category</option>
<option value={"meeting"}>Meeting</option>
<option value={"workhours"}>Work Hours</option>
<option value={"business"}>Business</option>
<option value={"holiday"}>Holiday</option>
<option value={"getTogether"}>Get-Together</option>
<option value={"gifts"}>Gifts</option>
<option value={"birthday"}>Birthday</option>
<option value={"anniversary"}>Anniversary</option>
<option value={"others"}>Others</option>
</select>
Here's how I'm trying to do it.
const [eventCategory, setEventCategory] = useState();
const handleEventCategory = (e)=>{
setEventCategory(e.target.value);
console.log(eventCategory);
}
It is giving the values randomly from the the options. Please help me figure this out. Thanks