这就是我现在所拥有的
$(document).ready(function() {
var inputs = $('input[name="BPSUBPT"], input[name="BPSUPQ"]');
$(inputs).click(function() {
var total = 0;
$(inputs).filter(':checked').each(function() {
// Now including the - sign
var value = ($(this).val()).match(/\$(-?[0-9]*)/)[1];
if (value) {
// I'm now ADDing the total
// total = total + parseInt(value);
total += parseInt(value);
}
});
$('#total').html('$' + total);
$('#BPSUBA').val('$' + total);
});
$('input[name="BPSUBPT"]').click(function() {
$(this).blur();
$('#BPSUBPP').val($(this).val());
})
$('input[name="BPSUPQ"]').click(function() {
$(this).blur();
$('#BPSUDA').val($(this).val());
});
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<p>Baby Plan<br />
<span class="wpcf7-form-control-wrap BPSUBPT"><span class="wpcf7-form-control wpcf7-radio radio-vertical" id="BPSUBPT"><span class="wpcf7-list-item first"><input type="radio" name="BPSUBPT" value="Baby Plan $300.00 3 Sessions" /> <span class="wpcf7-list-item-label">Baby Plan $300.00 3 Sessions</span></span><span class="wpcf7-list-item last"><input type="radio" name="BPSUBPT" value="Baby Plan $500.00 4 Sessions" /> <span class="wpcf7-list-item-label">Baby Plan $500.00 4 Sessions</span></span></span></span> </p>
<p>Did you have a Newborn session With ADP? <br />
<span class="wpcf7-form-control-wrap BPSUPQ"><span class="wpcf7-form-control wpcf7-radio radio-vertical" id="BPSUPQ"><span class="wpcf7-list-item first"><input type="radio" name="BPSUPQ" value="Yes $-150 off" /> <span class="wpcf7-list-item-label">Yes $-150 off</span></span><span class="wpcf7-list-item last"><input type="radio" name="BPSUPQ" value="No $000.00" /> <span class="wpcf7-list-item-label">No $000.00</span></span></span></span></p>
<p>Baby Plan Totals: <br />
Baby Plan Price: <span class="wpcf7-form-control-wrap BPSUBPP"><input type="text" name="BPSUBPP" value="" size="28" maxlength="28" class="wpcf7-form-control wpcf7-text" id="BPSUBPP" aria-invalid="false" /></span><br />
Discount Amount: <span class="wpcf7-form-control-wrap BPSUDA"><input type="text" name="BPSUDA" value="" size="10" maxlength="10" class="wpcf7-form-control wpcf7-text" id="BPSUDA" aria-invalid="false" /></span><br />
Balance Amount: <span class="wpcf7-form-control-wrap BPSUBA"><input type="text" name="BPSUBA" value="" size="8" maxlength="8" class="wpcf7-form-control wpcf7-text" id="BPSUBA" aria-invalid="false" /></span></p>
<p>Total Price: <span id="total"></span></p>
&#13;
我正在使用联系表单7创建一个会员表单,我需要添加一个单选按钮菜单以回复问题,并添加一个相应的输入字段,该字段将被减去,用于&#39;金额&# 39;从另一组单选按钮。创建订单很容易,但现在我想要的是我想要的数量&#39;值被隐藏,直到响应者点击回复电台。并根据回复&#39;进行更改。已从“回复”中选择单选按钮已被选中。假设我们在&#39;回复&#39;中有两个选项。单选按钮菜单,即:
1.是 2.No
<p>Did you have a Newborn session With ADP? <br />
[radio BPSUPQ id:BPSUPQ class:radio-vertical "Yes" "No"]
并且每个回复都有相应的金额设置,例如:
1.是= - $ 150(关闭) 2.NO = $ 000
现在我想要的是我希望输入字段为&#39;折扣金额&#39;从单选按钮中选择不同的回复选项时显示不同的值。例如,如果回复“是”&#39;选中,然后价值&#39; - $ 150.00&#39;应该在文本输入字段中显示金额,它应该根据选择的选项而不断变化。
Baby Plan Price: [text BPSUBPP 28/28 id:BPSUBPP]
我认为这可以使用javascript完成,但由于我对此很新,我发现它有点困难。这就是基本形式的样子。
<p>Baby Plan<br />
[radio BPSUBPT id:BPSUBPT class:radio-vertical "Baby Plan $300.00 3 Sessions" "Baby Plan $500.00 4 Sessions"] </p>
<p>Did you have a Newborn session With ADP? <br />
[radio BPSUPQ id:BPSUPQ class:radio-vertical "Yes$ -150 off" "No"]
<p>Baby Plan Totals: <br />
Baby Plan Price: [text BPSUBPP 28/28 id:BPSUBPP]
Discount Amount: [text BPSUDA 8/8 id:BPSUDA]
Total Price: <span id="total"></span
现在我有它的工作,所以它可以减去并显示折扣,我的单选按钮看起来像这样。
<p>Did you have a Newborn session With ADP? <br />
[radio BPSUPQ id:BPSUPQ class:radio-vertical "Yes $-150 off" "No"]
我的java脚本
<script>
$(document).ready(function() {
var inputs = $('input[name="BPSUBPT"], input[name="BPSUPQ"]');
$(inputs).click(function() {
var total = 0;
$(inputs).filter(':checked').each(function() {
// Now including the - sign
var value = ($(this).val()).match(/\$(-?[0-9]*)/)[1];
if (value) {
// I'm now ADDing the total
// total = total + parseInt(value);
total += parseInt(value);
}
});
$('#total').html('$' + total);
});
$('input[name="BPSUBPT"]').click(function() {
$(this).blur();
$('#BPSUBPP').val($(this).val());
});
$('input[name="BPSUPQ"]').click(function() {
$(this).blur();
$('#BPSUDA').val($(this).val());
});
});
</script>
有没有办法可以将它应用到我的java脚本中。
function updatePrice (el, priceLog, priceList) {
priceLog.value = '$' + priceList[el.getElementsByTagName('option')[el.selectedIndex].value.toLowerCase()];
}
var colorPrices = {
'yes' : $-100,
'No' : $000,
};
答案 0 :(得分:1)
我在这里找到了一些细节:
这适用于您通过组合的值进行选择:
var colorPrices = {
'yes' : -100,
'No' : 000
};