Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Pages - Customize & Extend
Unanswered

Can someone help me find what is wrong with my code

(0) ShareShare
ReportReport
Posted on by 32

I am adding the below piece of code to the content page of a portal webpage.  I don't

know what is wrong what it wont work on the portal. 

I am simply trying to show one field or hide it depending on another field.  This code used to work on power app portals but it doesn't seem to be anymore. 

 

$(document).ready(function(){
 $("#ahi_bres01q04species").change(SetFieldsVisibilityQ7b);
 //$("#ahi_bres01q04species").change();
});

function SetFieldsVisibilityQ7b() {
 var selectedValue = $("#ahi_bres01q04species").val();

 if (selectedValue !== null && selectedValue === "100000005")
 {
 $("#ahi_bres01q05mgmtsystem_label").closest("tr").hide().attr('aria-hidden', 'true');
 $("#ahi_bres01q05mgmtsystem").prop('required',true).closest("tr").show().attr('aria-hidden', 'false').attr('aria-required', 'true');
 }
 else
 {
 $("#ahi_bres01q05mgmtsystem_label").closest("tr").hide().attr('aria-hidden', 'true');
 $("#ahi_bres01q05mgmtsystem").prop('required',false).closest("tr").show().attr('aria-hidden', 'false').attr('aria-required', 'false');
 }
}

 

Categories:
  • Saud Ali Profile Picture
    812 Super User 2024 Season 1 on at
    Re: Can someone help me find what is wrong with my code

    Hi @ahilisa ,

     

    As @OliverRodrigues pointed out, it seems to be issue with your condition. Try debug your code if condition is evaluating correctly.

     

    Thanks,

    Saud

     

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

  • oliver.rodrigues Profile Picture
    9,319 Most Valuable Professional on at
    Re: Can someone help me find what is wrong with my code

    did you try to debug? or even just adding a few console.logs to see where it might not be working?

     

    my first guess is on the following validation:

     if (selectedValue !== null && selectedValue === "100000005")

     I am nearly sure that opionset value is an INT and not a string, because you are comparing with the triple equal operator "===", it is validating value + datatype, which might not be matching

     

    you can play in the browser console to see if that's the issue

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

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Pages

#1
Fubar Profile Picture

Fubar 69 Super User 2025 Season 1

#2
oliver.rodrigues Profile Picture

oliver.rodrigues 49 Most Valuable Professional

#3
Jon Unzueta Profile Picture

Jon Unzueta 43

Featured topics