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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Hiding fields based on...
Power Pages
Unanswered

Hiding fields based on email value AND boolean yes/no field

(0) ShareShare
ReportReport
Posted on by 35

Hello! 

I have a page on my portal that requires a bit of customization through JavaScript. I would like to hide fields based on an email address entered, which works fine. However, when the user enters the email domain that will show some fields, I would like to apply additional formatting. 

 

$(document).ready(function () {

$("#emailaddress1").change(onShowHideEmployeeFields);

onShowHideEmployeeFields();

});

function onShowHideEmployeeFields() {

var varEmail = $("#emailaddress1").val()

//alert(varEmail)

if (varEmail.includes("@example.org")) {

$('#xxx_employeeid').parent().parent().show();

$('#xxx_employeeid').prop('required', true);

$('#xxx_employeeid').closest(".control").prev().addClass("required");

$('#xxx_defaultfacilityid').parent().parent().show();

$('#xxx_defaultfacilityid').prop('required', true);

$('#xxx_defaultfacilityid').closest(".control").prev().addClass("required");

$('#xxx_positiontitle').parent().parent().show();

$('#xxx_judicialofficer').parent().parent().show();

$('#xxx_judicialofficer').prop('required', true);

$('#xxx_judicialofficer').closest(".control").prev().addClass("required");

$('#xxx_jopositiontitle').parent().parent().show();

}

else {

$('#xxx_employeeid').parent().parent().hide();

$('#xxx_defaultfacilityid').parent().parent().hide();

$('xxx_defaultfacilityid_label').parent().parent().hide();

$('xxx_positiontitle_label').parent().parent().hide();

$('#xxx_positiontitle').parent().parent().hide();

$('#xxx_judicialofficer').parent().parent().hide();

$('#xxx_jopositiontitle').parent().parent().hide();

}

}

function onDisplaySectionChange() {

var varJO= $("#xxx_judicialofficer").find("input[type='radio']:checked").val();

//alert(varJO)

if (varJO === true) {

    $('xxx_jopositiontitle').parent().parent().show();

}

else {

$('xxx_jopositiontitle').parent().parent().hide();

}

}

The first part of my code works fine. However, I'm trying to show the JO Position Title field IF the Judicial Officer Yes/No boolean field is Yes. 

 

Any thoughts on this?

Categories:
I have the same question (0)
  • AK91 Profile Picture
    35 on at

    Bump

  • Community Power Platform Member Profile Picture
    on at

    @aakk9911,

    Is this the function you are having issues with ?

     

    function onDisplaySectionChange() {
    
    var varJO= $("#xxx_judicialofficer").find("input[type='radio']:checked").val();
    
    //alert(varJO)
    
    if (varJO === true) {
    
     $('xxx_jopositiontitle').parent().parent().show();
    
     }
    
    else {
    
     $('xxx_jopositiontitle').parent().parent().hide();
    
     }
    
    }

     

    Try replacing it with below codes

     

     $('#xxx_judicialofficer').change(function () {
    
    		var varJO= $("#xxx_judicialofficer").val();
    		
    		//alert(varJO)
    		
    		if (varJO === 1) {
    		
    			$('xxx_jopositiontitle').parent().parent().show();
    		
    		 }
    		
    		else {
    		
    		 $('xxx_jopositiontitle').parent().parent().hide();
    		
    		 }
    		}

     

  • AK91 Profile Picture
    35 on at

    Hi @Anonymous 

     

    Thanks for the reply and suggestion. Unfortunately, the code you provided did not hide the JO Position field when the Judicial Officer? boolean field was marked 'Yes' -

     

    aakk9911_0-1647968048859.png

    I deleted all the other code just to test this one piece for the JO Position Title and the results were the same. Would you happen to have any other suggestions?

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Fubar Profile Picture

Fubar 74 Super User 2025 Season 2

#2
Jerry-IN Profile Picture

Jerry-IN 55

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard