我手动构建了这个,并且它在localhost中运行良好,但是必须将它集成到Gravity Forms中,并且使用新ID丢失了一些所需的功能。无论如何,它都会显示customer-information
div。我似乎永远无法在此处显示代码,所以如果您愿意,我可以在http://jsbin.com/laqoxe/edit?html,js,output
这是javascript:
jQuery(document).ready(function($) {
//Hide all but 1st field
$("#field_6_12").hide(); //Are you a current client?
$("#field_6_13").hide(); //Are you a currently receiving?
$("#field_6_14").hide(); //Are you a currently working?
$("#field_6_15").hide(); //Are you currently unable to work?
$("#customer-information").hide();
// build variables
var interested = $('input[type=radio][name=input_11]'),
current = $("input[type=radio][name=input_12]"),
currentlyReceiving = $("input[type=radio][name=input_13]"),
currentlyWorking = $("input[type=radio][name=input_14]"),
unable = $("input[type=radio][name=input_15]"),
fname = $("input[type=radio][name=input_6]"),
lname = $("input[type=radio][name=input_7]"),
phone = $("input[type=radio][name=input_8]"),
email = $("input[type=radio][name=input_9]"),
message = $("input[type=radio][name=input_10]");
//submitButton = $("input[type=submit] [id=gform_submit_button_6]");
//Conditionals
//====================================
//if interested changes, show current
interested.change(function() {
$("#field_6_12").show(); //this shows next area no matter what
}); // END interested change function
//Begins when the .current changes:
current.change(function() {
//if veterans && current client yes:
if (interested.val() == 'Veterans Benefits' && current.val() == 'Yes') {
$('#customer-information').show();
//if veteran && current client no:
} else if (interested.val() == 'Veterans Benefits' && current.val() == 'No') {
$('#customer-information').show();
//if SSD && current client no:
} else if (interested.val() == 'Social Security Disability' && current.val() == 'No') {
$('#field_6_13').show(); //show currently Receiving
//if Both && current client no:
} else if (interested.val() == 'Both' && current.val() == 'No') {
$('#field_6_13').show(); //show currently Receiving
}
}); //current change function
//begins with currentlyReceiving change
currentlyReceiving.change(function() {
$('#field_6_14').show(); // show currentlyWorking (no matter what, on change.)
});
//begins with currentlyWorking change
currentlyWorking.change(function() {
$('#field_6_15').show(); // show unable (to work) (no matter what, on change.)
});
//begins with unable to work change
currentlyReceiving.change(function() {
$('#customer-information').show(); // show #customer-information (no matter what, on change.)
});
}); //doc ready
<form>
<ul id='gform_fields_6' class='gform_fields top_label form_sublabel_below description_below'>
<li id='field_6_11' class='gfield interested field_sublabel_below field_description_below'>
<label class='gfield_label'>Are you interested in Social Security Disability or Veterans' Disability Benefits?</label>
<div class='ginput_container ginput_container_radio'>
<ul class='gfield_radio' id='input_6_11'>
<li class='gchoice_6_11_0'>
<input name='input_11' type='radio' value='Veterans Benefits' id='choice_6_11_0' tabindex='1' />
<label for='choice_6_11_0' id='label_6_11_0'>Veterans Benefits</label>
</li>
<li class='gchoice_6_11_1'>
<input name='input_11' type='radio' value='Social Security Disability' id='choice_6_11_1' tabindex='2' />
<label for='choice_6_11_1' id='label_6_11_1'>Social Security Disability</label>
</li>
<li class='gchoice_6_11_2'>
<input name='input_11' type='radio' value='Both' id='choice_6_11_2' tabindex='3' />
<label for='choice_6_11_2' id='label_6_11_2'>Both</label>
</li>
</ul>
</div>
</li>
<li id='field_6_12' class='gfield current field_sublabel_below field_description_below'>
<label class='gfield_label'>Are you a current client?</label>
<div class='ginput_container ginput_container_radio'>
<ul class='gfield_radio' id='input_6_12'>
<li class='gchoice_6_12_0'>
<input name='input_12' type='radio' value='Yes' id='choice_6_12_0' tabindex='4' />
<label for='choice_6_12_0' id='label_6_12_0'>Yes</label>
</li>
<li class='gchoice_6_12_1'>
<input name='input_12' type='radio' value='No' id='choice_6_12_1' tabindex='5' />
<label for='choice_6_12_1' id='label_6_12_1'>No</label>
</li>
</ul>
</div>
</li>
<li id='field_6_13' class='gfield currentlyReceiving field_sublabel_below field_description_below'>
<label class='gfield_label'>Are you currently receiving Social Security Disablity?</label>
<div class='ginput_container ginput_container_radio'>
<ul class='gfield_radio' id='input_6_13'>
<li class='gchoice_6_13_0'>
<input name='input_13' type='radio' value='Yes' id='choice_6_13_0' tabindex='6' />
<label for='choice_6_13_0' id='label_6_13_0'>Yes</label>
</li>
<li class='gchoice_6_13_1'>
<input name='input_13' type='radio' value='No' id='choice_6_13_1' tabindex='7' />
<label for='choice_6_13_1' id='label_6_13_1'>No</label>
</li>
</ul>
</div>
</li>
<li id='field_6_14' class='gfield currentlyWorking field_sublabel_below field_description_below'>
<label class='gfield_label'>Are you currently working more than 10 hours per week?</label>
<div class='ginput_container ginput_container_radio'>
<ul class='gfield_radio' id='input_6_14'>
<li class='gchoice_6_14_0'>
<input name='input_14' type='radio' value='Yes' id='choice_6_14_0' tabindex='8' />
<label for='choice_6_14_0' id='label_6_14_0'>Yes</label>
</li>
<li class='gchoice_6_14_1'>
<input name='input_14' type='radio' value='No' id='choice_6_14_1' tabindex='9' />
<label for='choice_6_14_1' id='label_6_14_1'>No</label>
</li>
</ul>
</div>
</li>
<li id='field_6_15' class='gfield unable field_sublabel_below field_description_below'>
<label class='gfield_label'>Are you unable to work a full time job because of your disability?</label>
<div class='ginput_container ginput_container_radio'>
<ul class='gfield_radio' id='input_6_15'>
<li class='gchoice_6_15_0'>
<input name='input_15' type='radio' value='Yes' id='choice_6_15_0' tabindex='10' />
<label for='choice_6_15_0' id='label_6_15_0'>Yes</label>
</li>
<li class='gchoice_6_15_1'>
<input name='input_15' type='radio' value='No' id='choice_6_15_1' tabindex='11' />
<label for='choice_6_15_1' id='label_6_15_1'>No</label>
</li>
</ul>
</div>
</li>
<div id="customer-information">
<li id='field_6_6' class='gfield stepSix field_sublabel_below field_description_below'>
<label class='gfield_label' for='input_6_6'>First Name</label>
<div class='ginput_container ginput_container_text'>
<input name='input_6' id='input_6_6' type='text' value='' class='medium' tabindex='12' />
</div>
</li>
<li id='field_6_7' class='gfield stepSix field_sublabel_below field_description_below'>
<label class='gfield_label' for='input_6_7'>Last Name</label>
<div class='ginput_container ginput_container_text'>
<input name='input_7' id='input_6_7' type='text' value='' class='medium' tabindex='13' />
</div>
</li>
<li id='field_6_8' class='gfield stepSix field_sublabel_below field_description_below'>
<label class='gfield_label' for='input_6_8'>Phone</label>
<div class='ginput_container ginput_container_phone'>
<input name='input_8' id='input_6_8' type='text' value='' class='medium' tabindex='14' />
</div>
</li>
<li id='field_6_9' class='gfield stepSix field_sublabel_below field_description_below'>
<label class='gfield_label' for='input_6_9'>Email</label>
<div class='ginput_container ginput_container_email'>
<input name='input_9' id='input_6_9' type='text' value='' class='medium' tabindex='15' />
</div>
</li>
<li id='field_6_10' class='gfield stepSix field_sublabel_below field_description_below'>
<label class='gfield_label' for='input_6_10'>Message</label>
<div class='ginput_container ginput_container_textarea'>
<textarea name='input_10' id='input_6_10' class='textarea medium' tabindex='16' rows='10' cols='50'></textarea>
</div>
</li>
</div>
<!--/customer-information -->
</ul>
</form>
答案 0 :(得分:0)
看起来单选按钮始终保持退伍军人福利价值。所以我认为你应该触发current.change(function(){
内部单选按钮的更改
例如,如果你移动
interested = $('input[type=radio][name=input_11]:checked'),
current = $('input[type=radio][name=input_12]:checked'),
应该有效