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

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

(0) ShareShare
ReportReport
Posted on by

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

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