function increasePrice(checkbox) {
var increase = parseInt(checkbox.value);
var price_inputs = document.getElementsByClassName("price-input");
var price_span = document.getElementsByClassName("price");
for (var i = 0; i < price_inputs.length; i++) {
var price = price_inputs.item(i);
var newValue = parseInt(price.value);
if (checkbox.checked) {
var newValue = newValue + increase;
} else {
var newValue = newValue - increase;
}
price_span.item(i).innerHTML = newValue;
price.value = newValue;
}
};
<h1>Holiday Tour</h1>
<form role="form" action="" method="post" class="f1">
<label><input onclick="increasePrice(this)" type="checkbox" value="500" > Chennai Trip (Rs.500/-)</label>
<label><input class="price-input" type="radio" name="optradio" value="4700">
1 PERSON - <b>Cost Rs.<span class="price">4700</span>/- </b>
</label>
</form>
<p>how to display above checked amount to the below field</p>
<p><label><input type="radio" name="optradio">
Full Payment <b>Cost Rs /-</b>
</label></p>
<p><label><input type="radio" name="optradio">
Advance Payment <b>Cost Rs /-</b>
</label></p>
<p>Tour Package : </p>
我无法在全部金额字段中显示选中的单选按钮值。我有10个旅行套餐和旅行详细信息,当有人单击某个特定旅行对应的旅行数量时,将会显示旅行名称
答案 0 :(得分:0)
为解决此问题,我创建了一个新的Javascript函数来更新全价单选按钮和标签。您可以使用类似的方法进行预付款。实际上,每次调用DescribeDBInstances()
时,我只会调用更新预付款方式,以使它们保持同步。
updateFullPayment
我还更新了您的Javascript函数,以调用我的Java代码并传递当前选择的价格,以便总价始终处于更新状态。
function updateFullPayment(radio) {
var value = parseInt(radio.value)
var full_payment = document.getElementById("full-price");
var full_payment_radio = document.getElementById("full-price-radio");
full_payment.innerHTML = value;
full_payment_radio.value = value;
};
HTML现在看起来像这样。单击价格单选按钮将调用我创建的更新功能。
function increasePrice(checkbox) {
var increase = parseInt(checkbox.value);
var price_inputs = document.getElementsByClassName("price-input");
var price_span = document.getElementsByClassName("price");
for (var i = 0; i < price_inputs.length; i++) {
var price = price_inputs.item(i);
var newValue = parseInt(price.value);
if (price_inputs.item(i).checked) {
var selectedPrice = price_inputs.item(i);
}
if (checkbox.checked) {
var newValue = newValue + increase;
} else {
var newValue = newValue - increase;
}
price_span.item(i).innerHTML = newValue;
price.value = newValue;
}
updateFullPayment(selectedPrice);
};