Page 1 of 1

Hide/Show fields base on condition

Posted: 2019-10-11 23:15
by Moh Youba
Hello

I am using latest version of AppGini 5.80

I am trying the code below to hide/show field base on condition
when I enter this code, it is not work

$j(function(){
$j('#selectionner-container').on('change', function(){

if($j('#selectionner').val() == 'GESTION DU PERSONNEL'){

$j('#periode').parents('.form-group').hide();

}else{

$j('#periode').parents('.form-group').show();

};
});
});

but when I enter like this, it is work. It seems the first condition is not working. Any idea please.

$j(function(){
$j('#selectionner-container').on('change', function(){

if($j('#selectionner').val() == 'GESTION DU PERSONNEL'){

$j('#periode').parents('.form-group').hide();

}else{

$j('#periode').parents('.form-group').hide();

};
});
});


even if I enter the code like this, it hide the field

$j(function(){
$j('#selectionner-container').on('change', function(){

if($j('#selectionner').val() == 'GESTION DU PERSONNEL'){

$j('#periode').parents('.form-group').show();

}else{

$j('#periode').parents('.form-group').hide();

};
});
});

Thank you

Re: Hide/Show fields base on condition

Posted: 2019-10-12 09:59
by pbottcher
Hi,

please check the value of

$j('#selectionner').val()

As this is a lookup, it will not contain the actual value, but the key to the lookup-table.

Re: Hide/Show fields base on condition

Posted: 2019-10-12 10:34
by Moh Youba
Thank you

Re: Hide/Show fields base on condition

Posted: 2019-11-18 23:07
by Moh Youba
Hello

now it is working for me, but after I save, the field is displayed
my code

$j('#type_client').on('change', function(){
if($j('#type_client').val() == "PROFESSIONNEL"){
$j('#raison_sociale').parents('.form-group').show();
$j('#raison_sociale').focus().select();
}else{
$j('#raison_sociale').parents('.form-group').hide();
}
})

if it is a new record, it is working well, but after the record is saved, the hided field displayed again.