web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Pages / Setting Choice Field B...
Power Pages
Unanswered

Setting Choice Field Based on Choice Field Using Custom JavaScript

(0) ShareShare
ReportReport
Posted on by 13

Hello! I'm pretty new to Power Pages and I've been back and forth with this code trying to figure out how I can set up my Power Pages form. I want to make it so that if a user chooses Holiday in one choice field, that it also selects "Holiday" in another choice field. This is the code I have so far:

$(document).ready(function () {
$("#cr53b_otdateclassification").change(onDisplaySectionChange);
onDisplaySectionChange();
});

function onDisplaySectionChange() {
var varOTDateClassification = $('#cr53b_otdateclassification').find("option:selected").text();
var varOTClassification = $('#cr53b_otclassification').val()
if (varOTDateClassification === "Holiday") {$('#cr53b_otclassification').val('Holiday');};
 
}

If I could get some help, I'd greatly appreciate it!

 

 

Categories:
I have the same question (0)
  • Verified answer
    RogersTheSherif Profile Picture
    13 on at

    Figured it out!

    $(document).ready(function () {
    $("#cr53b_otdateclassification").change(onDisplaySectionChange);
    onDisplaySectionChange();
    });

    function onDisplaySectionChange() {
    var varOTDateClassification = $('#cr53b_otdateclassification').find("option:selected").text();
    var varOTClassification = $('#cr53b_otclassification').val();

    if (varOTDateClassification === "Holiday") {
    // You need to check the HTML on your Power Pages site and look for the option number. Power Pages Custom JS doesn't recognize the text values, so you need to reference the option # value.
    $('#cr53b_otclassification').val('872150002');
    }
    }

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Pages

#1
Jerry-IN Profile Picture

Jerry-IN 71

#2
Fubar Profile Picture

Fubar 62 Super User 2025 Season 2

#3
sannavajjala87 Profile Picture

sannavajjala87 31

Last 30 days Overall leaderboard