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 :
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 "";
// };
I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at

    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

  • Leah Ju Profile Picture
    Microsoft Employee on at

    Hi,

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

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 Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 51 Super User 2026 Season 1

#1
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 51 Most Valuable Professional

#3
Nagaraju_Matta Profile Picture

Nagaraju_Matta 50

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans