Hide/Show extra fields based on Dropdown selection

The recommended method of customizing your AppGini-generated application is through hooks. But sometimes you might need to add functionality not accessible through hooks. You can discuss this here.
Post Reply
User avatar
aarlauskas
Veteran Member
Posts: 127
Joined: 2019-04-28 18:03
Location: Medway, UK

Hide/Show extra fields based on Dropdown selection

Post by aarlauskas » 2019-10-29 21:03

Hi, not sure if this was answered, but I have seen some other people asking similar question.. I really need a solution for my scenario:
When creating a record, this needs to be flexible in a way that I could add one or multiple items on the same record, but keep the fields hidden if they are not required for this moment. So basically, let say I'm attending a site to swap part on machine. I then need three fields to fill-in for the replacement of this part in Appgini (Machine Nr, Part Model and Part Serial Nr). But then I go elsewhere and I need to swap three parts on three machines. So I would like to have an option to un-hide additional fields by selecting the number of the machines from a drop-down menu. Lets say I select '3 Terminals' from drop-down list and this gives me additional fields for these part swaps to be recorded. Can someone help with this? I can pay symbolic price for the coffee (sorry I'm not earning anything from this, just trying to make my day easier... ) Thank You.

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

Re: Hide/Show extra fields based on Dropdown selection

Post by pbottcher » 2019-10-29 21:40

Hi,

you may try

Code: Select all

$j('#FIELD-container').on('change', function(e){
  if(e.added.text == "3 Terminals") {
    $j('YOURFIELDLIST').show();
  }
})
where FIELD need to be recplace with the fieldname of the dropdown and YOURFIELDLIST is the list of field that you want to unhide.
something like
'#field1, #field2, #field3'
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.

Post Reply