I want to update a text input field every time a checkbox is checked(true). Can someone please advise how can this be done please?.
I'm trying to click a checkbox and update another input field. Every time the checkbox is checked I want to add the date to a string.
Currently, my string value is being overwritten by the new value. I want it to be a string and not an array.
const [checkboxCheckedTrue, setCheckboxStatus] = useState(false);
const [updateMyMsg, setmyMsg] = React.useState("");
useEffect((): void => {
if (checkboxCheckedTrue) {
var a = new Date();
const myMsg = "My Date is" + a;
setmyMsg(myMsg );
}
});
My expected string should look like the following:
"Thu Sep 15 2022 15:52:41 <br/> Thu Sep 15 2022 15:52:41 <br/> Thu Sep 15 2022 15:52:41"