This is my html:
$("input[name=item_35174][value='1']").prop('checked', true);
$("input[name='item_35174']").change(function() {
$("label[for=item_35317], input[type=radio][name=item_35317]").toggle(this.value == "0");
$("label[for=item_35175], input#item_35175").hide();
$("label[for=item_35176], input#item_35176").hide();
$("label[for=item_35177], input#item_35177").hide();
});
$("input[name='item_35174']:checked").change(); //trigger correct state onload
$("input[name='item_35317']").change(function() {
$("label[for=item_35175], input#item_35175").toggle(this.value == "1");
$("label[for=item_35176], input#item_35176").toggle(this.value == "1");
$("label[for=item_35177], input#item_35177").toggle(this.value == "1");
});
$("input[name='item_35317']:checked").change(); //trigger correct state onload
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="mx_form_row">
<label for="item_35174">Naar luchthaven brengen: *</label>
<div class="mx_form_input">
<div class="mx_form_input_option">
<input type="radio" name="item_35174" value="0" /> Ja
</div>
<div class="mx_form_input_option">
<input type="radio" name="item_35174" value="1" /> Nee
</div>
</div>
</div>
<div class="mx_form_label">Vul hier enkel de gegevens in van uw ophaaladres naar de luchthaven</div>
<div class="mx_form_spacer"></div>
<div class="mx_form_row">
<label for="item_35317">Ophaaladres</label>
<div class="mx_form_input">
<div class="mx_form_input_option">
<input type="radio" name="item_35317" value="0" /> Zelfde als bij 'Uw gegevens'
</div>
<div class="mx_form_input_option">
<input type="radio" name="item_35317" value="1" /> Ander adres
</div>
</div>
</div>
<div class="mx_form_row">
<label for="item_35175">Adres</label>
<div class="mx_form_input">
<input type="text" name="item_35175" id="item_35175" value="" />
</div>
</div>
<div class="mx_form_row">
<label for="item_35176">Postcode</label>
<div class="mx_form_input">
<input type="text" name="item_35176" id="item_35176" value="" />
</div>
</div>
<div class="mx_form_row">
<label for="item_35177">Woonplaats</label>
<div class="mx_form_input">
<input type="text" name="item_35177" id="item_35177" value="" />
https://jsfiddle.net/cn24m5t8/
For what i have now its almost working, but the only thing is that when i hide Item: item_35317 i want also the rest of the label: "Zelfde als bij ‘Uw gegevens’" and "Ander adres"
I can nothing change in the html, i can only change it in the js or css.
Maybe some one know how i can hide this
2
Answers
When the radio buttons are hidden, the labels can be selected and hidden using JQuery
This code might work, try it:
try this one