这是我要创建此表单的代码,如果您输入了价格、数量和折扣百分比等所有信息,并且折扣金额显示为小计,总折扣金额为折扣金额除以 100,然后乘以小计。小计是通过将价格乘以数量得出的。总数是通过将小计乘以折扣得出的,正如您所看到的,我已经完成了表格,并且我几乎拥有 javascript 上的所有代码,但似乎我无法使其与折扣一起使用。请帮忙 !
JS:
$('#CAT_Custom_490527').keyup(function () {
var quantity = $("#CAT_Custom_490527").val();
var iPrice = $("#CAT_Custom_490526").val();
var subtotal = quantity * iPrice;
$("#CAT_Custom_491101").val(subtotal);
var x = $("#CAT_Custom_491074").val();
var y = 100
var division = x / y
var multi = division * subtotal
$("CAT_Custom_491074").val(division);
var total = subtotal * multi;
$("#CAT_Custom_490531").val(total);
// sets the total price input to the quantity * price
});
HTML:
<tr>
<td>
<label for="CAT_Custom_490526">Precio <span class="req">*</span>
</label>
<br />
<input type="text" maxlength="255" name="CAT_Custom_490526" id="CAT_Custom_490526" class="cat_textbox" />
</td>
</tr>
<tr>
<td>
<label for="CAT_Custom_490527">Cantidad <span class="req">*</span>
</label>
<br />
<input type="text" maxlength="255" name="CAT_Custom_490527" id="CAT_Custom_490527" class="cat_textbox" />
</td>
</tr>
<tr>
<td>
<label for="CAT_Custom_491074">%Descuento</label>
<br />
<input type="text" maxlength="255" name="CAT_Custom_491074" id="CAT_Custom_491074" class="cat_textbox" />
</td>
</tr>
<tr>
<td>
<label for="CAT_Custom_491218">Descuento</label>
<br />
<input type="text" maxlength="255" name="CAT_Custom_491218" id="CAT_Custom_491218" class="cat_textbox" />
</td>
</tr>
<tr>
<td>
<label for="CAT_Custom_491101">Subtotal</label>
<br />
<input type="text" maxlength="255" name="CAT_Custom_491101" id="CAT_Custom_491101" class="cat_textbox" />
</td>
</tr>
<tr>
<td>
<label for="CAT_Custom_490531">Total <span class="req">*</span>
</label>
<br />
<input type="text" maxlength="255" name="CAT_Custom_490531" id="CAT_Custom_490531" class="cat_textbox" />
</td>
</tr>