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 :
Power Platform Community / Forums / Power Pages / Setting Choice Field B...
Power Pages
Answered

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
rezarizvii Profile Picture

rezarizvii 64

#2
DP_Prabh Profile Picture

DP_Prabh 34

#3
oliver.rodrigues Profile Picture

oliver.rodrigues 30 Most Valuable Professional

Last 30 days Overall leaderboard