Hide/Show fields base on condition

Please report bugs and any annoyances here. Kindly include all possible details: steps to reproduce, expected result, actual result, screenshots, ... etc.
Post Reply
Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

Hide/Show fields base on condition

Post by Moh Youba » 2019-10-11 23:15

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

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Hide/Show fields base on condition

Post by pbottcher » 2019-10-12 09:59

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.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

Re: Hide/Show fields base on condition

Post by Moh Youba » 2019-10-12 10:34

Thank you

Moh Youba
Veteran Member
Posts: 228
Joined: 2017-03-12 09:31

Re: Hide/Show fields base on condition

Post by Moh Youba » 2019-11-18 23:07

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.

Post Reply