Page 1 of 1

conditional show / hide

Posted: 2018-12-08 09:10
by baudwalker
I am looking for assistance in the following.

When creating or editing a record I would like to hide certain fields after a particular selection
EG
among others there are the following fields
varchar - multi select field 'position', Required selection are 'secretary' and 'captain'
varchar - 'dates'
varchar - 'time'
text - 'comments'

What is required is if 'secretary' is selected hide 'dates' and 'time' and show all other fields
if captain is selected hide 'comments' and show all other fields

pseudo code.

if position = secretary then hide 'dates' and 'time' else hide 'comments'

thank you in anticipation

Barry

Re: conditional show / hide

Posted: 2018-12-08 11:57
by jsetzer
Hi Barry,

have a look here. Is this what you need?

https://forums.appgini.com/phpbb/viewto ... 8934#p8550

Feel free to contact me in case you need support.

Regards,
Jan

https://www.bizzworxx.com

Re: conditional show / hide

Posted: 2018-12-10 06:36
by baudwalker
Thank you Jan,
I will see if I can, hopefully, adapt the code to my requirements,

Barry

Re: conditional show / hide

Posted: 2018-12-16 01:34
by Alisson

Code: Select all

jQuery(function(){
  jQuery('#position-container').on('change', function() {
    if(jQuery('#department-container').val() == 'secretary'){
      $j('#dates').parents('.form-group').hide();
      $j('#time').parents('.form-group').hide();
    }
     else {
      $j('#comments').parents('.form-group').hide();
      };      
  });
});