I'm trying to hide select fields according to the radio button I can hide the inputs, but the select fields I'm not getting, could anyone help me?
Form:
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12" for="first-name">Forma de pagamento <span class="required">*</span>
</label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="radio" name="custom_field[account][1]" id="id-custom_field-account-1-1" value="1" <?php echo ($vtipoCadastro == '1')?'checked':'';?> > Boleto Conta Um
<br />
<input type="radio" name="custom_field[account][1]" id="id-custom_field-account-1-2" value="2" <?php echo ($vtipo == '2')?'checked':'';?> > Cartão Conta Um
<br />
<input type="radio" name="custom_field[account][1]" id="id-custom_field-account-1-3" value="3" <?php echo ($vtipo == '3')?'checked':'';?> > Espécie <small><b>(R$)</b></small>
<br />
<input type="radio" name="custom_field[account][1]" id="id-custom_field-account-1-4" value="4" <?php echo ($vtipo == '4')?'checked':'';?> > Depósito/Transferência
<br />
<input type="radio" name="custom_field[account][1]" id="id-custom_field-account-1-5" value="5" <?php echo ($vtipo == '5')?'checked':'';?> > Cheque
<br />
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Qtde. Parcelas <span class="required">*</span></small>
</label>
<div class="col-md-3 col-sm-3 col-xs-12">
<select class="form-control col-md-7 col-xs-12 select2_single forma" tabindex="-1" id="select-custom-field2" name="custom_field[account][2]">
<option></option>
<?php
for($a=1; $a<=12; $a++){
?>
<option value="<?php echo $a;?>" <?php if($a == $vqtdeparcelas){ echo ' selected="selected"'; } ?> ><?php echo $a;?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Dia Vencimento <span class="required">*</span></small>
</label>
<div class="col-md-3 col-sm-3 col-xs-12">
<select class="form-control col-md-7 col-xs-12 select2_single forma" tabindex="-1" id="select-custom-field3" name="custom_field[account][3]">
<option></option>
<?php
$b = array(5,15); // ######## DIAS PARA PAGAMENTO
foreach($b as $key => $value){
?>
<option value="<?php echo $a;?>" <?php if($a == $vvencimento){ echo ' selected="selected"'; } ?> ><?php echo $value;?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Data do recebimento<span class="required">*</span>
</label>
<div class="col-md-3 col-sm-3 col-xs-12">
<input type="text" class="form-control col-md-7 col-xs-12 forma" name="custom_field[account][4]" id="input-custom-field4" value="<?php echo $vdatarecebimentoespecie; ?>" data-inputmask="'mask' : '99/99/9999'"><br>
</div>
</div>
script:
$(document).ready(function() {
$('input:radio[name="custom_field[account][1]"]').on("change", function() {
if (this.checked && this.value == '1') {
$("#select-custom-field2, #select-custom-field3").show();
$("#input-custom-field4").hide();
} if (this.checked && this.value == '2') {
$("#select-custom-field2, #select-custom-field3").show();
$("#input-custom-field4").hide();
} if (this.checked && this.value == '3') {
$("#input-custom-field4").show();
$("#select-custom-field2, #select-custom-field3").hide();
} if (this.checked && this.value == '4') {
$("#input-custom-field4").show();
$("#select-custom-field2, #select-custom-field3").hide();
} if (this.checked && this.value == '5') {
$("#select-custom-field2, #select-custom-field3").show();
$("#input-custom-field4").hide();
}
});
});
And the CSS:
input.form-control.forma {
display: none;
}
select.form-control.forma {
display: none;
}