Still new to all things reactjs and JavaScript, so this maybe something simple, but I have yet to find an example when searching online.
I would like to build a table with each row having an input box and a onClick/submit that will then send the input amount entered for that row in the function or just some way to access the input data for that row. The rows are built from an array saved in state.
Here is a stripped down code of where I am currently at. This is only the table that gets called by a higher level container that passes down biweeklyPays and saveChanges.
function PayoutsTable(props) {
var payoutRows = []
var biweeklyPays = props.biweeklyPays
for (let b of biweeklyPays) {
payoutRows.push(
<tr>
<td>{b.user.first_name + ' ' + b.user.last_name}</td>
<td>{b.biweeklyPay.payoutAmount}</td>
<td><input className="form-control" type="number" id="payoutAmount" step=".01" min="0" /></td>
<td><button className="btn btn-primary" onClick={() => props.saveChanges(b)}>Submit</button></td>
</tr>
)
}
return (
<div>
<table className="table table-responsive table-striped">
<thead>
<tr>
<th>Name</th>
<th>Payout Amount</th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
{payoutRows}
</tbody>
</table>
</div>
)
}