Display child fields only after master field is selected

More
2 years 2 months ago - 2 years 2 months ago #81303 by iamrobert
I wanted to hide the child fields until the master field is selected. You can do it via FLEXIcontent types.



If we have 4 fields like this with LIBRARY as the master:


The LIBRARY field is setup as follows:



Steps:

1. Hide the Slave/Children fields in item Form - Backend



Code:
// HIDE THE SLAVE FIELDS $('#label_outer_fcfield_208, #container_fcfield_208').hide(); $('#label_outer_fcfield_209, #container_fcfield_209').hide(); $('#label_outer_fcfield_210, #container_fcfield_210').hide();



2. Display the Slave/Children fields on load (if already saved):

Code:
//SHOW ON LOAD     if ($('#custom_library_cat_0 input[value="care"]').is(':checked') == true) {           $('#label_outer_fcfield_208, #container_fcfield_208').show();        }          if ($('#custom_library_cat_0 input[value="training"]').is(':checked') == true) {           $('#label_outer_fcfield_209, #container_fcfield_209').show();      }            if ($('#custom_library_cat_0 input[value="health"]').is(':checked') == true) {           $('#label_outer_fcfield_210, #container_fcfield_210').show();       }

3. When changing the radio switch values:
Code:
//DISPLAY ON CLICK     $('input[name="custom[library_cat][0]"]').change(       function () {         //RADIO CARE VALUE          if (this.checked && this.value == 'care') {           console.log('care');           $('#label_outer_fcfield_209, #container_fcfield_209').hide();           $('#label_outer_fcfield_210, #container_fcfield_210').hide();           $('#label_outer_fcfield_208, #container_fcfield_208').show();         }         //RADIO HEALTH VALUE          if (this.checked && this.value == 'training') {           console.log('training');           $('#label_outer_fcfield_208, #container_fcfield_208').hide();           $('#label_outer_fcfield_210, #container_fcfield_210').hide();           $('#label_outer_fcfield_209, #container_fcfield_209').show();         }         //RADIO HEALTH VALUE          if (this.checked && this.value == 'health') {           console.log('health');           $('#label_outer_fcfield_208, #container_fcfield_208').hide();           $('#label_outer_fcfield_209, #container_fcfield_209').hide();           $('#label_outer_fcfield_210, #container_fcfield_210').show();         }       });

Hope this helps.
Last edit: 2 years 2 months ago by iamrobert.

Please Log in or Create an account to join the conversation.

More
2 years 2 months ago #81307 by micker
thanks !!!!

FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Time to create page: 0.249 seconds
Save
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline