在形式中,当rate(另一个文本输入)的值时,我要插入amount(文本输入)的值。将要插入的数值是速率和数量的乘积。数量值取自数据库。这里,rate的值将被用户插入。 插入金额后,该值不能更改。我怎样才能做到这一点?当另一个输入文本被赋予另一个值时,在输入文本中自动插入值
我曾尝试下面的代码,但结果显示为零每次:
查看
<div class="form-group">
<label for="exampleInputPassword1">Rate</label>
<input type="text" class="form-control" name="rate" placeholder="Rate" required>
</div>
<div class="form-group">
<label>Quantity</label>
<input type="text" class="form-control" name="quantity" placeholder="quantity" value="<?php echo $object['sheet']; ?> " required readonly>
</div>
<div class="form-group">
<label for="exampleInputPassword2">Amount</label>
<?php
$sheet = $object['sheet'];
$rate = $this->input->post('rate');
$amount = $sheet*$rate;
echo $amount;
}
?>
<input type="text" class="form-control" name="amount" value="<?php echo $amount;?>" placeholder="Amount" required>
</div>
我是否正确,你想改变输入金额的速度*数量的价值每当价格变化的价值? – Martijn
是的,您正在写入并且在插入价值iof率时必须显示金额的值。 –