<form method="post" action="/Tests/Post/">
<fieldset>
<legend>What is Your Favorite Pet?</legend>
<input type="checkbox" name="favorite_pet" value="Cats">Cats<br>
<input type="checkbox" name="favorite_pet" value="Dogs">Dogs<br>
<input type="checkbox" name="favorite_pet" value="Birds">Birds<br>
<br>
<input type="submit" value="Submit now" />
</fieldset>
</form>
const [multipleName, setMultipleName] = useState<string[]>([]);
const [ownerid, setOwnerId] = useState(" ");
const storeMultiName = (name: any, ownerid: any) => {
setOwnerId(ownerid);
let statusExist = false;
multipleName?.find((val) => {
if (val === name) {
statusExist = true;
}
});
if (statusExist) {
const a = [...multipleName];
const b = a.filter((val) => val !== name);
setMultipleName(b);
} else {
const a = [...multipleName];
a.push(name);
setMultipleName(a);
}
};