Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Suggested answer

I have a portal form with a select field called Device Type and a selection "Phone" . When this selection is made I need a hidden field on the form called "select OS" to become visible. The code below does not work.

(0) ShareShare
ReportReport
Posted on by 55
$(document).ready(function () {
debugger;
//formContext = executionContext.getFormContext();
//console.log("Do any of these fire?");
//onDisplaySectionChange(formContext);
showHideFieldsandTab();
var deviceSelect = $("#finraesd_devicetype");
var phoneOS = $("Case[data-name='finraesd_selectphoneos']");
console.log("Is selectDevice real?"+deviceSelect);
console.log("Is phone os real?"+phoneOS);
mainFunc(deviceSelect, phoneOS);
});

function showHideFieldsandTab() {
$("#finraesd_devicetype").change(mainFunc);
}

// function onDisplaySectionChange(context) {
// //var selectedValue = getSelectValue($("#finraesd_devicetype"));
// console.log("Did this function go?");
// var selectedValue = context.getAttribute($("#finraesd_devicetype")).getValue();
// console.log("What is select value?\n"+selectedValue);
// if (selectedValue == "283420000") {
// $("Case[data-name='finraesd_selectphoneos']").parent().show(); /// and .hide();
// }
// else {
// $("Case[data-name='finraesd_SelectPhoneOS']").parent().hide(); /// and .hide();;
// }
// }

// 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 "";
// };


//let deviceSelect = document.getElementById("finraesd_devicetype");
//let phoneOS = document.getElementById("finraesd_selectphoneos");
//console.log("Is device null?"+deviceSelect);
//console.log("Is phone null?"+phoneOS);
//phoneOS.hidden=true;
function mainFunc(deviceSelect, phoneOS) {
//deviceSelect.addEventListener("change", function() {
console.log("There has been a change to the Device Select box");
console.log("What even is??\n"+deviceSelect[0].value);
if (deviceSelect.value != "283420000") {
console.log("Not Phone Value");
phoneOS.parent().parent().hide();
// for(i=0;i<furColor.length;i++) {
// furColor[i].hidden=false;
// }
}
// if (animalSelect.value !== "cat") {
// for(i=0;i<furColor.length;i++) {
// furColor[i].hidden=true;
// }
// }
//})
}
// $(document).ready(function () {
// debugger;
// onDisplaySectionChange();
// showHideFieldsandTab();
// });

// function showHideFieldsandTab() {
// $("#iii_callingonbehalfof").change(onDisplaySectionChange);
// }

// function onDisplaySectionChange() {
// var selectedValue = GetRadioSelectedValue($('#iii_callingonbehalfof'));
// if (selectedValue != "1") {
// $("table[data-name='Your_Information']").parent().show(); /// and .hide();
// }
// else {
// $("table[data-name='Your_Information']").parent().hide(); /// and .hide();;
// }
// }

// 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 "";
// };
  • Leah Ju Profile Picture
    Microsoft Employee on at
    RE: I have a portal form with a select field called Device Type and a selection "Phone" . When this selection is made I need a hidden field on the form called "select OS" to become visible. The code below does not work.

    Hi,

    Any updates? Please feel free to contact me if you have any questions.

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: I have a portal form with a select field called Device Type and a selection "Phone" . When this selection is made I need a hidden field on the form called "select OS" to become visible. The code below does not work.

    Hi Bigred57,

    According to your description, I recovered your scene, i can achieve it successfully!

    Two fields:

    pastedimage1665044343734v1.pngpastedimage1665044363136v2.png

    Add them to the form you are using in portal.

    JS code:

    $(document).ready(function () {
    MyFieldChanged();
    $('#new_devicetype').on("change", MyFieldChanged);
    });

    function MyFieldChanged() {
    var selectedValue = $('#new_devicetype').val();
    //alert(selectedValue);
    if (!!selectedValue && selectedValue == "100000000") {
    $("#new_selectos").closest("td").find("div.control, div.info").show();
    }
    else {
    $("#new_selectos").closest("td").find("div.control, div.info").hide();
    }
    }

    Test Result:

    pastedimage1665044488345v3.png

    pastedimage1665044511754v4.png

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,245 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,927 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans