I am trying to write an handlesubmit function that can change the state for multiple forms. I am having trouble with retrieving the input value and using it in my handlesubmit function. Also when I try to setstate, the values disappear from the table.
handleSubmit = (event) => {
event.preventDefault();
let value = this.element.value;
this.setState({[event.target.id]: value});
}
<td>
{this.state.benchMax}
</td>
<td>
{this.state.ohpMax}
</td>
<td>
<form id="benchMax" onSubmit={this.handleSubmit}>
<input type="number" ref={el => this.element = el}></input>
<input type="submit" value="Update!"></input>
</form>
</td>
<td>
<form id="ohpMax" onSubmit={this.handleSubmit}>
<input type="number" ref={el => this.element = el}></input>
<input type="submit" value="Update!"></input>
</form>
</td>
The results don't display in the table, and the changes aren't tracked.