私はこれを使っていcalculate total
ます。これが全体のスクリプトです
<!DOCTYPE HTML>
<html lang="en-IN">
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/jquery1.7.2.js"></script>
</head>
<body>
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#quantity, #unit_price, #tax").on('change',function(event){
var subtotal = jQuery("#quantity").val() * jQuery("#unit_price").val();
var total = subtotal + (subtotal * jQuery("#tax").val() / 100);
jQuery("#total").val(total);
});
});
</script>
<table>
<tr>
<td>
<label for="unitcost">Unitcost</label>
<input type="text" id="unit_price" />
</td>
</tr>
<tr>
<td>
<label for="quantity">Quantity</label>
<input type="text" id="quantity" />
</td>
</tr>
<tr>
<td>
<label for="tax">Tax</label>
<input type="text" id="tax" />
</td>
</tr>
<tr>
<td>
<label for="total">Total</label>
<input type="text" id="total" />
</td>
</tr>
</table>
</body>
</html>
しかし、1つの問題があります。Every time
をclick the text field
取得する必要がありresult
ます。ユーザーがそうするときにそれが欲しいですenter the values in their fields it should show the total without click on input fields
。私はjquery ajax
ここでうまくいくと思いますが、これでそれを実装する方法がわかりません。どんな助けや提案もかなりのものになります。