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 / If a value is selected...
Power Pages
Answered

If a value is selected from drop down then a default value should be displayed in other dropdown

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Screenshot (20).pngIf in state drop down Uttar Pradesh is selected and it should automatically display its capital as Lucknow in Capital drop down and same for all other states.

i.e default value should be displayed if states are choosen

Categories:
I have the same question (0)
  • Verified answer
    Christian Leverenz Profile Picture
    1,214 on at

    Hi @Anonymous ,

    when i do this kind of things in projects, i need two things:

    • a list which describes the dependencies (so, what is the capital of a selected state)
    • a changehandler for the stateselector

    As jquery is on portals around, you could do it with jquery.

    The code might look something like this (not tested, just written):

    let mycapitals = [

    { "state" : 1234, "capital" : 3456 }

    ,{ "state" : 5678, "capital" : 78910 }

    ]; // a list of realtion capital to state

     

    let changefunction = (function(src, tgt, rels) {

    var jqtgt = $("#" + tgt); // get the jquery field for the capital

    var jqsrc=$("#" + src); // get the jquery field for the state

    let mychangefun = function() { // create the changefunction

    var srcval = jqsrc.val(); // get the statevalue

    var tgtvalentry = rels.find(e => e.state == srcval); // find the capitalentry

    if(tgtvalentry) { // did we find one?

    jqtgt.val(tgtvalentry.capital); // yes, set the value of the capital

    }

    };

    mychangefun(); // initalize in case of read with the right value

    jqsrc.change(mychangefun); // attach the changefunction to the stateselctor

    return mychangefun; // return back the changefunction of needed to be attached somewhere else

    })("stateselectid","capitalselectid",mycapitals);

     

    just replace stateselectid with your attributename of the state and the capitalselectid with the name of the capitalattribute. May be you have to adjust something, when the capital already has a value.

     

    You can place this code in the entitybasicform or in the template you are using.

    Hope this helps,

      Christian

     

    PS i think, there is only one capital per state. Why should the user select another one? (well, not my challenge 🙂 )

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

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Pages

#1
sannavajjala87 Profile Picture

sannavajjala87 42 Super User 2026 Season 1

#2
Valantis Profile Picture

Valantis 33

#3
11manish Profile Picture

11manish 20

Last 30 days Overall leaderboard