I’m having an issue getting Java Script to work for a Dynamics 365 portal form.
The code is supposed to show hide an address field on the form when the option for physical subscriber is selected. This is a yes no Boolean.
Here is the code:
`$(document).ready(function () {
// Bind the onDisplaySectionChange function to the change event of the element with ID "ds_VoiceSubscriber".
$("#ds_VoiceSubscriber").change(onDisplaySectionChange);
// Calling onDisplaySectionChange immediately when the page loads.
onDisplaySectionChange();
});
// Function to show or hide fields and tabs based on the selected value.
function onDisplaySectionChange() {
var selectedValue = GetRadioSelectedValue($('#ds_VoiceSubscriber'));
if (selectedValue === "1") {
// Show the parent of the element with ID "Address1_Line1".
$("#Address1_Line1").parent().show();
} else {
// Hide the parent of the element with ID "Address1_Line1".
$("#Address1_Line1").parent().hide();
}
}
// Function to get the selected value of a radio button group.
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 "";
};`