<input type="radio" name="CAT_Custom_332258_327" value="Standard" class="member-type" />
<input type="radio" name="CAT_Custom_332258_327" value="Youth" class="member-type" />
<input type="radio" name="CAT_Custom_332258_327" value="Family Add-On" class="member-type" />
<input type="radio" name="highflight" value="print" class="highflight-type" />
<input type="radio" name="highflight" value="digital" class="highflight-type" />
<input type="radio" name="highflight" value="printdigital" class="highflight-type" />
2 セットのラジオ ボタンと「金額」テキスト フィールド (#Amount) があります。2 番目のラジオ ボタン セット (.highflight-type) の選択を変更すると、両方のラジオ ボタン セットの値に基づいて Amount テキスト フィールドが更新されます。
$(".highflight-type").click(function(){
if($(this).val()=="print") {
if($('.member-type').val()=="Standard") {
$('#Amount').val('35');
}
if($('.member-type').val()=="Youth") {
$('#Amount').val('35');
}
}
if($(this).val()=="digital") {
if($('.member-type').val()=="Youth") {
$('#Amount').val('10');
}
if($('.member-type').val()=="Standard") {
$('#Amount').val('25');
}
}
if($(this).val()=="printdigital") {
if($('.member-type').val()=="Standard") {
$('#Amount').val('50');
}
if($('.member-type').val()=="Youth") {
$('#Amount').val('35');
}
}
});
しかし、最初のラジオ ボタン セット (.member-type) で "Youth" を選択し、2 番目のラジオ ボタンを "digital" に変更すると、$10 ではなく $25 の #Amount 値が得られます。.highflight-type ラジオ ボタンの選択を変更するときに、アラートを使用して DOM の .member-type 値を確認しました。