我目前正在使用此代码使输入框出现和消失,具体取决于我的用户选择的内容
<label class="title">Is the Primary Contact a Director of the corporation?</label>
<input type="radio"{if freeform:mp_data:type=="Yes"} checked="checked"{/if} name="type" id="primary_contact_director_1" value="Yes"> Yes</input><br>
<input type="radio"{if freeform:mp_data:type=="No"} checked="checked"{/if} name="type" id="primary_contact_director_2" value="No"> No</input><br><br>
<div id="Yes_box">
</div>
<div id="No_box">
<label class="title">Director's First Name:</label>
<input type="text" name="director_first_name" class="form" value="{freeform:mp_data:director_first_name}">
<label class="title">Director's Last Name:</label>
<input type="text" name="director_last_name" class="form" value="{freeform:mp_data:director_last_name}">
<label class="title">Address:</label>
<input type="text" name="director_address" class="form" value="{freeform:mp_data:director_address}">
<label class="title">City:</label>
<input type="text" name="director_city" class="form" value="{freeform:mp_data:director_city}">
<label class="title">State:</label>
<input type="text" name="director_state" class="form" value="{freeform:mp_data:director_state}">
<label class="title">Zip Code</label>
<input type="text" name="director_zip_code" class="form" value="{freeform:mp_data:director_zip_code}">
</div>
<script>
$(document).ready(function(){
var myRadio = $('input[name=type]');
var checkedValue = myRadio.filter(':checked').val();
if(checkedValue=='No'){
$('#No_box').show();
}else{
$('#No_box').hide();
}
$('#Yes_box_two').hide();
});
</script>
但是,我需要名称字段才能显示结果,所以我想更改 input[name=type] 以调用 id 而不是名称