商品名ドロップダウン、数量フィールド&量フィールドを含むフォームがあります。商品名を選択したときに、選択した商品の価格と数量を合計金額欄に表示する場合は、データベースから価格を取得します。私はJqueryを使いたい。フォームの2つのフィールドから値を取得し、第3フィールドで乗算を表示
これは私のコードです:
<div class="section row mb10" style="">
<label for="ordered-product" class="field-label col-md-2 text-center"><i class="fa fa-product"></i></label>
<div class="col-md-3">
<label class="field select">
<select name="orderedproduct[]" id="orderedproduct">
<option>Select Ordered Product</option>
<?php
$query="SELECT * FROM product_list";
$res=mysql_query($query) or die(mysql_error());
while($row=mysql_fetch_array($res)){
echo "<option value='". $row['product_id'] ."'>" .$row['product_name'] ."</option>" ;
}
?>
</select>
</label>
</div>
<label for="product-qty" class="field-label col-md-1 text-center"><i class="fa fa-cubes"></i></label>
<div class="col-md-2">
<label for="product-qty" class="field prepend-icon">
<input type="text" name="productqty[]" id="productqty" class="gui-input" placeholder="Quantity">
</label>
</div>
<label for="order-amount" class="field-label col-md-1 text-center"><i class="fa fa-inr"></i></label>
<div class="col-md-2">
<label for="order-ammount" class="field prepend-icon">
<input type="text" name="orderammount[]" id="orderammount" class="gui-input" disable placeholder="Total Amount">
</label>
</div>
</div>
任意の助けが理解されるであろう。ありがとうございました。
のjQuery:
$('#orderedproduct','#productqty').change(function(){
var oproductname = $(this).val();
$.ajax(
type:'POST';
data:{oproductname:oproductname},
url:'ajax pages/amount.php',
success:function(data){
$('#orderedamount').val(data);
}
});
});
する必要があります願っています私たちがあなたのためにコード化すると期待しているときではなく、 – madalinivascu
あなたはjavascriptやjqueryでそれを行うことができます。いくつかのコードを最初に試して、あなたのコードが動作していない場合は助けを依頼してください – geeth
@ jeth私はこのjqueryを行っているが、私はこれを初めて知っているので、私はあまりそれを知らない。 –