web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Javascript hides secti...
Power Pages
Unanswered

Javascript hides section in Form by yes or no column but now I want to add a second

(1) ShareShare
ReportReport
Posted on by 249

Hello devs,


I have less experience with Javascript. Can someone help me out? Because I don't now how to achieve a second yes or no colomn and hide section part. I can but then the first stops working:)

 

This works good:

 

 

$(document).ready(function() {
console.log(555, "JS-hiding elements");
$(".tab-title").hide();
});

$(document).ready(function () {
 debugger;
 onDisplaySectionChange();
 showHideFieldsandTab();

});

function showHideFieldsandTab() {
 $("#bij_factuuradresanders").change(onDisplaySectionChange);
}

function onDisplaySectionChange() {
 var selectedValue = GetRadioSelectedValue($('#bij_factuuradresanders'));
 if (selectedValue != "0") {
 $("table[data-name='tab_2_section_4']").parent().show(); /// and .hide();
 }
 else {
 $("table[data-name='tab_2_section_4']").parent().hide(); /// and .hide();;
 }
}

GetRadioSelectedValue = function(input) {

 if (!!$(input).find("input[type=radio]")) {
 var controlName = $(input).find("input[type=radio]").first().attr("name");
 if (!!controlName) {
 return $("input[name='" + controlName + "']:checked").val();
 }
 }
 return "";
};

 

 

But now I want to add another, this one (if I paste below then only this one work):

 

 

function showHideFieldsandTab() {
 $("#bij_tweedereferentienummeropgeven").change(onDisplaySectionChange);
}

function onDisplaySectionChange() {
 var selectedValue2 = GetRadioSelectedValue($('#bij_tweedereferentienummeropgeven'));
 if (selectedValue2 != "0") {
 $("table[data-name='tab_2_section_7']").parent().show(); /// and .hide();
 }
 else {
 $("table[data-name='tab_2_section_7']").parent().hide(); /// and .hide();;
 }
}

 

 

 Thank you so much

Categories:
  • Manar Profile Picture
    72 on at

    Hi,

    If you want to hide 2 sections based on bij_factuuradresanders value, then i would recommend trying this 

     

     

    function showHideFieldsandTab() {
     $("#bij_factuuradresanders").change(onDisplaySectionChange);
    }
    
    function onDisplaySectionChange() {
     var selectedValue = GetRadioSelectedValue($('#bij_factuuradresanders'));
     if (selectedValue != "0") {
     $("table[data-name='tab_2_section_4']").closest('fieldset').show(); 
     $("table[data-name='tab_2_section_7']").closest('fieldset').show(); 
    
     }
     else {
     $("table[data-name='tab_2_section_4']").closest('fieldset').hide(); 
     $("table[data-name='tab_2_section_7']").closest('fieldset').hide(); 
     }
    }

     

     

  • Robin1988 Profile Picture
    249 on at

    Hi @Manar thank you for your reply. But they are two separate ones. So "#bij_factuuradresanders" has an section and further on in the form is "#bij_tweedereferentienummeropgeven" with its own section. 

  • Manar Profile Picture
    72 on at

    my bad, then you need to rename the new function (lets call it showHideFieldsandTab2) and call it onload. try that

     

    function showHideFieldsandTab2() {
     $("#bij_tweedereferentienummeropgeven").change(onDisplaySectionChange);
    }
    
    function onDisplaySectionChange() {
     var selectedValue2 = GetRadioSelectedValue($('#bij_tweedereferentienummeropgeven'));
     if (selectedValue2 != "0") {
     $("table[data-name='tab_2_section_7']").parent().show(); /// and .hide();
     }
     else {
     $("table[data-name='tab_2_section_7']").parent().hide(); /// and .hide();;
     }
    }

     

    $(document).ready(function () {
     debugger;
     onDisplaySectionChange();
     showHideFieldsandTab();
     showHideFieldsandTab2();
    
    
    });

     

  • Robin1988 Profile Picture
    249 on at

    Hello @Manar  sorry to say but not working here.  I'll try some more!

  • Robin1988 Profile Picture
    249 on at

    @Manar

    We missed:

    onDisplaySectionChange();
     
    Thx for the help!
     
    Now it's working (maybe it can be done much smarter but Ok):
     

     

    $(document).ready(function () {
     debugger;
     onDisplaySectionChange();
     onDisplaySectionChange2();
     showHideFieldsandTab();
     showHideFieldsandTab2();
    });
    
    function showHideFieldsandTab() {
     $("#bij_factuuradresanders").change(onDisplaySectionChange);
    }
    
    function showHideFieldsandTab2() {
     $("#bij_tweedereferentienummeropgeven").change(onDisplaySectionChange2);
    }
    
    function onDisplaySectionChange() {
     var selectedValue = GetRadioSelectedValue($('#bij_factuuradresanders'));
     if (selectedValue != "0") {
     $("table[data-name='tab_2_section_4']").parent().show(); /// and .hide();
     }
     else {
     $("table[data-name='tab_2_section_4']").parent().hide(); /// and .hide();;
     }
    }
    
    function onDisplaySectionChange2() {
     var selectedValue2 = GetRadioSelectedValue($('#bij_tweedereferentienummeropgeven'));
     if (selectedValue2 != "0") {
     $("table[data-name='tab_2_section_7']").parent().show(); /// and .hide();
     }
     else {
     $("table[data-name='tab_2_section_7']").parent().hide(); /// and .hide();;
     }
    }
    
    GetRadioSelectedValue = function(input) {
    
     if (!!$(input).find("input[type=radio]")) {
     var controlName = $(input).find("input[type=radio]").first().attr("name");
     if (!!controlName) {
     return $("input[name='" + controlName + "']:checked").val();
     }
     }
     return "";
    };

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Pages

#1
Mohsin Ali Profile Picture

Mohsin Ali 35

#2
M Bilal Khan Profile Picture

M Bilal Khan 33

#3
11manish Profile Picture

11manish 21 Super User 2026 Season 2

Last 30 days Overall leaderboard