I have made same thing using form Form.control . Here is the code and screenshot
{product.countInStock > 0 && (
<ListGroupItem>
<Row>
<Col>Qty</Col>
<Form.Control
as="select"
value={qty}
onChange={(e) => setQty(e.target.value)}
>
{[...Array(product.countInStock).keys()].map((x) => (
<option key={x + 1} value={x + 1}>
{x + 1}
</option>
))}
</Form.Control>
</Row>
</ListGroupItem>
)}
but I want the same thing in input tag format like this
<input
type="number"
value={qty}
onChange={(e) => setQty(e.target.valueAsNumber)}
min="0"
max={product.countInStock}
/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.