• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

[SOLVED] Js issue | Hide and Show Elements function not working

marcq

Member
Hi,

I have created a form with several fields among others 2 radio button elements.

Each combination of those 2 radio button elements show | hide other elements.

I have used a similar function with another form which is working fine.

No clue why it is not working.

Would appreciate your support.

Cheers, marc


JavaScript:
function doShowHide44() {
    var form = Fabrik.getBlock('form_44');
    var type_rappel = form.formElements.get('gprh_fabrik_user_reminder___type_rappel');
    var no_rappel = form.formElements.get('gprh_fabrik_user_reminder___no_rappel');
    var bloc_contact_cr1 = form.formElements.get('gprh_fabrik_user_reminder___bloc_contact_cr1');
    var bloc_contact_cr2 = form.formElements.get('gprh_fabrik_user_reminder___bloc_contact_cr2');
    var bloc_contact_cr3 = form.formElements.get('gprh_fabrik_user_reminder___bloc_contact_cr3');
    var bloc_contact_fr1 = form.formElements.get('gprh_fabrik_user_reminder___bloc_contact_fr1');
    var bloc_contact_fr2 = form.formElements.get('gprh_fabrik_user_reminder___bloc_contact_fr2');
    var bloc_contact_fr3 = form.formElements.get('gprh_fabrik_user_reminder___bloc_contact_fr3');
    var bloc_tel_contact_cr1 = form.formElements.get('gprh_fabrik_user_reminder___bloc_tel_contact_cr1');
    var bloc_tel_contact_cr2 = form.formElements.get('gprh_fabrik_user_reminder___bloc_tel_contact_cr2');
    var bloc_tel_contact_cr3 = form.formElements.get('gprh_fabrik_user_reminder___bloc_tel_contact_cr3');
    var bloc_tel_contact_fr1 = form.formElements.get('gprh_fabrik_user_reminder___bloc_tel_contact_fr1');
    var bloc_tel_contact_fr2 = form.formElements.get('gprh_fabrik_user_reminder___bloc_tel_contact_fr2');
    var bloc_tel_contact_fr3 = form.formElements.get('gprh_fabrik_user_reminder___bloc_tel_contact_fr3');
... etc

    if (type_rappel == '1' && no_rappel == '1') {

        bloc_contact_cr1.show();
        bloc_contact_cr2.hide();
        bloc_contact_cr3.hide();
        bloc_contact_fr1.hide();
        bloc_contact_fr2.hide();
        bloc_contact_fr3.hide();
        bloc_tel_contact_cr1.show();
        bloc_tel_contact_cr2.hide();
        bloc_tel_contact_cr3.hide();
        bloc_tel_contact_fr1.hide();
        bloc_tel_contact_fr2.hide();
        bloc_tel_contact_fr3.hide();
... etc

    } else if (type_rappel == '1' && no_rappel == '2') {

        bloc_contact_cr1.hide();
        bloc_contact_cr2.show();
        bloc_contact_cr3.hide();
        bloc_contact_fr1.hide();
        bloc_contact_fr2.hide();
        bloc_contact_fr3.hide();
        bloc_tel_contact_cr1.hide();
        bloc_tel_contact_cr2.show();
        bloc_tel_contact_cr3.hide();
        bloc_tel_contact_fr1.hide();
        bloc_tel_contact_fr2.hide();
        bloc_tel_contact_fr3.hide();
... etc

    } else if (type_rappel == '1' && no_rappel == '3') {

        bloc_contact_cr1.hide();
        bloc_contact_cr2.hide();
        bloc_contact_cr3.show();
        bloc_contact_fr1.hide();
        bloc_contact_fr2.hide();
        bloc_contact_fr3.hide();
        bloc_tel_contact_cr1.hide();
        bloc_tel_contact_cr2.hide();
        bloc_tel_contact_cr3.show();
        bloc_tel_contact_fr1.hide();
        bloc_tel_contact_fr2.hide();
        bloc_tel_contact_fr3.hide();
        bloc_introduction_cr1.hide();
        bloc_introduction_cr2.hide();
        bloc_introduction_cr3.show();
        bloc_introduction_fr1.hide();
        bloc_introduction_fr2.hide();
        bloc_introduction_fr3.hide();
        bloc_situation_cr1.hide();
        bloc_situation_cr2.hide();
        bloc_situation_cr3.show();
        bloc_situation_fr1.hide();
        bloc_situation_fr2.hide();
        bloc_situation_fr3.hide();
        bloc_attentes_cr1.hide();
        bloc_attentes_cr2.hide();
        bloc_attentes_cr3.show();
        bloc_attentes_fr1.hide();
        bloc_attentes_fr2.hide();
        bloc_attentes_fr3.hide();
        bloc_politesse_cr1.hide();
        bloc_politesse_cr2.hide();
        bloc_politesse_cr3.show();
        bloc_politesse_fr1.hide();
        bloc_politesse_fr2.hide();
        bloc_politesse_fr3.hide();

    } else if  (type_rappel == '2' && no_rappel == '1') {

        bloc_contact_cr1.hide();
        bloc_contact_cr2.hide();
        bloc_contact_cr3.hide();
        bloc_contact_fr1.show();
        bloc_contact_fr2.hide();
        bloc_contact_fr3.hide();
        bloc_tel_contact_cr1.hide();
        bloc_tel_contact_cr2.hide();
        bloc_tel_contact_cr3.hide();
        bloc_tel_contact_fr1.show();
        bloc_tel_contact_fr2.hide();
        bloc_tel_contact_fr3.hide();
... etc

    } else if (type_rappel == '2' && no_rappel == '2') {

        bloc_contact_cr1.hide();
        bloc_contact_cr2.hide();
        bloc_contact_cr3.hide();
        bloc_contact_fr1.hide();
        bloc_contact_fr2.show();
        bloc_contact_fr3.hide();
        bloc_tel_contact_cr1.hide();
        bloc_tel_contact_cr2.hide();
        bloc_tel_contact_cr3.hide();
        bloc_tel_contact_fr1.hide();
        bloc_tel_contact_fr2.hide();
        bloc_tel_contact_fr3.hide();
... etc

    } else if (type_rappel == '2' && no_rappel == '3') {

        bloc_contact_cr1.hide();
        bloc_contact_cr2.hide();
        bloc_contact_cr3.hide();
        bloc_contact_fr1.hide();
        bloc_contact_fr2.hide();
        bloc_contact_fr3.show();
        bloc_tel_contact_cr1.hide();
        bloc_tel_contact_cr2.hide();
        bloc_tel_contact_cr3.hide();
        bloc_tel_contact_fr1.hide();
        bloc_tel_contact_fr2.hide();
        bloc_tel_contact_fr3.show();
... etc
    }
}

Please access My Fabrik Sites, Site Name GPRH to get more infos.

Thanks a lot in advance for your support.

Cheers, marc
 
What did you select as "Event"?
You can try "click" instead of "change" (or vice versa).
 
Hi troester, thanks for you reply.
I tried with click, change in the Element Javascript. Same result: fields are not shown or hidden.
Javascript code in element calling the function is : doShowHide44();
 
Please access My Fabrik Sites, Site Name GPRH to get more infos.

Those credentials don't work:

Vous ne pouvez pas acc?der ? l'administration de ce site.

I think the problem is

Code:
   var type_rappel = form.formElements.get('gprh_fabrik_user_reminder___type_rappel');
   var no_rappel = form.formElements.get('gprh_fabrik_user_reminder___no_rappel');

... blah blah ...

if(type_rappel =='1'&& no_rappel =='1'){

You are assigning the element object to those variables, then testing them expecting them to be values. Which would need to call getValue() on the object ...

Code:
if(type_rappel,getValue() =='1'&& no_rappel.getValue() =='1'){

... or assign getValue)( to those variables ...

Code:
 var type_rappel = form.formElements.get('gprh_fabrik_user_reminder___type_rappel').getValue();
   var no_rappel = form.formElements.get('gprh_fabrik_user_reminder___no_rappel').getValue();

-- hugh
 
Thank for you reply Hugh, it works fine now. Indeed, I forgot to get the value...
Happy new year, cheers, marc
 
We are in need of some funding.
More details.

Thank you.

Staff online

Members online

Back
Top