0
我想要執行一些計算並在div標籤中打印值。如何在jQuery中進行計算和打印值?
我想計算總和sum1 = (total * total2) + jsvar1;
和sum2 = (total1 * total2) + jsvar1;
。
接下來,我想在html div標記中顯示sum1
和sum2
值。
我怎麼能用我所擁有的完成這項工作?如果有人能幫我做到這一點,我將非常感激。非常感謝你。
這是我到目前爲止有:
jsvar1 = <?php
$sql9 = mysql_query("select room_rate from room_category where hotel_id='".$hotel_id."' and room_type = '".$var_value."' ");
$res9 = mysql_fetch_array($sql9);
$roomrate = $res9["room_rate"];
echo $roomrate;
?>;
document.write(jsvar1);
$(document).ready(function() {
$('#roomOptions #select1').change(function() {
var total = 0;
$('#roomOptions #select1').each(function() {
total+=parseInt($(this).val());
});
$('#roomOptions #roomOptions_total').html(total);
});
$('#roomOptions #select2').change(function() {
var total1 = 0;
$('#roomOptions #select2').each(function() {
total1+=parseInt($(this).val());
});
$('#roomOptions #roomOptions_total1').html(total1);
});
$('#roomOptions #select3').change(function() {
var total2 = 0;
$('#roomOptions #select3').each(function() {
total2+=parseInt($(this).val());
});
$('#roomOptions #roomOptions_total2').html(total2);
});
});
我想知道如何計算這些值? –