1
Hello,
I have an html where I want to hide or display some fields according to the button radio
selected. However it has not worked, I would like a help. Follow the code:
<script>
$( document ).ready(function() {
$("#input-custom-field2, #input-custom-field3, #input-custom-field4, #input-custom-field5, #input-custom-field6").hide();
});
$("input:radio[name=custom_field-account-1]").on("change", function () {
if($(this).val() == "1")
{
$("#input-custom-field2, #input-custom-field3").show();
$("#input-custom-field4, #input-custom-field5, #input-custom-field6").hide();
}
else if($(this).val() == "2")
{
$("#input-custom-field4, #input-custom-field5, #input-custom-field6").show();
$("#input-custom-field2, #input-custom-field3").hide();
}
});
</script>
<div class="radio">
<label>
<input type="radio" name="custom_field[account][1]" id="id-custom_field-account-1-1" value="1">
Pessoa Física
</label>
</div>
<div class="radio">
<label>
<input type="radio" name="custom_field[account][1]" id="id-custom_field-account-1-2" value="2">
Pessoa Jurídica
</label>
</div>
<input type="text" name="custom_field[account][4]" value="" placeholder="Razão Social" id="input-custom-field4" class="form-control" vk_1bc56="subscribed">
<input type="text" name="custom_field[account][5]" value="" placeholder="CNPJ" id="input-custom-field5" class="form-control" vk_1bc56="subscribed">
<input type="text" name="custom_field[account][6]" value="" placeholder="I.E" id="input-custom-field6" class="form-control" vk_1bc56="subscribed">
<input type="text" name="custom_field[account][3]" value="" placeholder="RG" id="input-custom-field3" class="form-control" vk_1bc56="subscribed">
<input type="text" name="custom_field[account][2]" value="" placeholder="CPF" id="input-custom-field2" class="form-control" vk_1bc56="subscribed">
there is a way to hide the fields on this page (this is the code that helped me, but on this checkout page, they appear blocked from start and not hidden, add a product to the cart and go to the page).
– Wendell
@Wendell what are the fields? I only see search products and receive promotions?
– Sergio
edited the answer, it is necessary to add a product to the cart and then go to the link I informed, soon after click continue and you will see the fields cnpj, ie, blocked and not hidden
– Wendell
@Wendell tests like this
$('[id^="input-payment-custom-field"]:disabled').closest('.form-group.custom-field').hide();
. Today I can’t help anymore, I’m swamped with work.– Sergio
did not work, but thanks for the help. When you can look, the code was like this: Code.
– Wendell
@Wendell in your codepen has some strange letters on
field
. Test run what I wrote up on the console there on the site and tell if it works.– Sergio
Let’s go continue this discussion in chat.
– Wendell