这个问题可能听起来很复杂,但我只想让允许输入的最大损坏数量小于正在输入的数量。我需要让另一个输入字段的输入基于另一个输入字段的输入。
下面是输入表单的代码:
`
<div id="addtransaction" class="col-12" style="display:none">
<div class="card overflow-auto">
<div class="card-body ">
<div class="row">
<h5 class="add-title text-center">Add Transaction</h5>
<form method="POST" action="inv-add.php" id="form1" class="needs-validation" novalidate>
<div class="row">
<div class="col-md-3">
<label for="customer" class="text-black"><strong>Customer</strong></label>
<input class="form-control" type="text" name="customer" maxlength="10" required >
</div>
<div class="col-md-3">
<label for="transaction" class="text-black"><strong>Transaction</strong></label>
<select class="form-control" name="transaction" required>
<option value="" disabled selected>Choose a transaction</option>
<option value="1">Regular</option>
<option value="2">Refill</option>
</select>
</div>
<div class="col-md-3">
<label for="item" class="text-black"><strong>Item</strong></label>
<select class="form-control" name="item" required>
<option value="" disabled selected>Choose an item</option>
<option value="0">Slim</option>
<option value="1">Round</option>
</select>
</div>
</div>
<div class="row">
<div class="col-md-3">
<label for="quantity" class="text-black"><strong>Quantity</strong></label>
<input class="form-control" type="number" min="0" oninput="this.value=this.value.slice(0,this.maxLength)" maxlength="2" name="quantity" required>
</div>
<div class="col-md-3">
<label for="price" class="text-black"><strong>Price per galon</strong></label>
<input class="form-control" type="number" min="0" oninput="this.value=this.value.slice(0,this.maxLength)" maxlength="4" name="price" placeholder="₱ 0.00" required >
</div>
<div class="col-md-3">
<label for="returns" class="text-black"><strong>Gallons returned</strong></label>
<input class="form-control" type="number" min="0" oninput="this.value=this.value.slice(0,this.maxLength)" maxlength="2" name="returns">
</div>
<div class="col-md-2">
<label for="damaged" class="text-black"><strong>Damaged</strong> </label>
<input class="form-control" type="number" min="0" oninput="this.value=this.value.slice(0,this.maxLength)" maxlength="2" name="damaged">
</div>
</div>
<div style="padding-top: 10px; display: flex; align-items: flex-end;">
<button type="submit" name="add" id="add" class="btn btn-primary add">Confirm</button>
</div>
</form>
</div>
</div>
</div>
`
1条答案
按热度按时间ibrsph3r1#
您可以使用setAttribute()方法来修改输入中允许的最大数目。
element.setAttribute(attributeName, attributeValue)
并在每次修改其他输入的值时调用此方法。