onchange选项值计算价格$price
是当前值和当前选项值0; 如果更改选项值则计算值选项值是产品的数量而不更改其 0 如果我们更改值是更改
<?php
print_r ($_POST);
$name=$_POST['name'];
$price=$_POST['price'];
?>
<div class="myaccount1_2">
<div class="deal_text"><?php echo $name; ?>.</div>
<div class="mypurchase_1">
<select class="select_new" name="val">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
</div>
<div class="mypurchase_1">£<?php echo $price; ?></div>
<div class="price"><b>£00.00 </b></div>
</div>
我希望在选择显示00.00
之后选择计算值显示
答案 0 :(得分:2)
使用以下jQUery代码:
$(document).ready(function(){
$("select[name=val]").change(function(){
var qnt = $(this).val();
var price = "<?php echo $price;?>";
var total = qnt*price;
$(".price").val('<b>£'+total+'</b>');
alert(qnt*price);
});
});
答案 1 :(得分:0)
使用此功能..
<script>
function calculate(value,price)
{
var div = document.getElementById('div_id');
div.innerHTML=value*price;
}
</script>
<select class="select_new" name="val" **onchange="calculate(this.value,'$price')"**)>
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>