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 / Can someone help me fi...
Power Pages
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:
  • oliver.rodrigues Profile Picture
    9,482 Most Valuable Professional on at

    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

  • Saud Ali Profile Picture
    812 Super User 2024 Season 1 on at

    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.

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 18

#2
11manish Profile Picture

11manish 16 Super User 2026 Season 2

#3
Harshit Chaubisa Profile Picture

Harshit Chaubisa 4

Last 30 days Overall leaderboard