1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

Select all on cascading dropdown as checkbox list

Discussion in 'Community' started by FilMar, Mar 13, 2019.

  1. FilMar

    FilMar Member

    Level: Community
    Is there a (more or less) easy way to have a 'select all' button or so on a dropdown rendered as checkbox list?

    I have a form where most of the time all or most of the options shown shall be selected so it would be nice to have the possibility to select them all at once.

    Or if there is an easy way to select them all by default, that can be a solution also (via Eval options?).

    Many thanks in advance,

    Greetings,

    Filip
     
  2. startpoint

    startpoint Active Member

    Level: Community
    Code (Javascript):
    //Check All options after form is loaded (valid only for databasejoin element).
    var all_checkBoxes = jQuery('#your_elem___name').find('.fabrikinput');
    all_checkBoxes.prop("checked", !all_checkBoxes.prop("checked"));
    Code (Javascript):
    //Check/Uncheck All options after click element databasejoin label.
    var elem = jQuery('#your_elem___name').closest('.fabrikElementContainer');
    jQuery(elem).on('click','.fabrikLabel', function(){
       var all_checkBoxes = jQuery(elem).find('.fabrikinput');
        all_checkBoxes.prop("checked", !all_checkBoxes.prop("checked"));
    })
     
    Last edited: Mar 13, 2019
  3. FilMar

    FilMar Member

    Level: Community
    Great,

    Works like a charm! I used the second version as the dropdown is a cascading dropdown who is not filled in at form load.

    Thank you very much

    Greetings,

    Filip
     

Share This Page