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
Your Answer
1 answers
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
Hot tools Tags
Hot Questions
Add leading zeroes to number in Java? [duplicate]
2025-12-30 13:44:01
JQuery, Spring MVC @RequestBody and JSON - making it work together
2025-12-30 13:22:11
document.getElementById vs jQuery $()
2025-12-30 13:01:06
CSS selector for "foo that contains bar"? [duplicate]
2025-12-30 12:43:08
MySQL performance: multiple tables vs. index on single table and partitions
2025-12-30 12:22:38
Popular tool
vc9-vc14 (32+64 bit) runtime library collection (link below)
Download the collection of runtime libraries required for phpStudy installation
VC9 32-bit
VC9 32-bit phpstudy integrated installation environment runtime library
PHP programmer toolbox full version
Programmer Toolbox v1.0 PHP Integrated Environment
VC11 32-bit
VC11 32-bit phpstudy integrated installation environment runtime library
SublimeText3 Chinese version
Chinese version, very easy to use
Hot Topics
Douyin level price list 1-75
20416
7
20416
7
wifi shows no ip assigned
13573
4
13573
4






