score:1

Accepted answer
  <form onsubmit={handleonsubmit}>
        <label>user name</label>
        <input type="text"  name="username" /><br/>
        <label>password</label>
        <input type="password"  name="password" /><br/>
        <input type="submit" value="submit" />
      </form>



 const handleonsubmit = (event) => {
    const formdata = new formdata(event.target);
    const formdetails = {};

    event.preventdefault();
    for (let entry of formdata.entries()) {
      formdetails[entry[0]] = entry[1];
    };
    console.log("formdetails", formdetails);
  }

score:1

you need to store the value

const [value, setvalue] = react.usestate();

then give your input a onchange={e => setvalue(e.target.value)}

i would change the id though

score:1

you are getting the input fields value from "formdata" on onsubmit.

const saveactivities = (event) => {
    event.preventdefault();
    const data = new formdata(event.target);

   // insert code to run the call to the backend
}

Related Query

More Query from same tag