亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

How to select multiple checkboxes in Reactjs
P粉950128819
P粉950128819 2024-04-06 18:55:21
0
1
852

I have an option list in which I want to select multiple checkboxes but am unable to do so, what is wrong with this code?

Sandbox URL

P粉950128819
P粉950128819

reply all(1)
P粉545218185

According to your requirements, you can change handleCheckboxQuestionInput to:

const handleCheckboxQuestionInput = (e) => {
    const answer = e.target.value;
    setSelectedAnswers((prevAnswers) => {
      if(prevAnswers.includes(answer)) {
        return prevAnswers.filter(e => e !== answer)
      } else {
        return [...prevAnswers, answer]
      }
    });
  };

and change at the input element to:

 handleCheckboxQuestionInput(e)}
 />

Hope it helps you

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template