Skip to main content

Notifications

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.

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
    Leah Ju 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
    Community Member 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 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans