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');
}
}
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.
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
Fubar
69
Super User 2025 Season 1
oliver.rodrigues
49
Most Valuable Professional
Jon Unzueta
43