Skip to main content

Notifications

Community site session details

Community site session details

Session Id : PetouZRTYp78C2z0XbqUvF
Power Pages - General Discussions
Suggested answer

Check/get selected options from a 'Choices' field using custom Javascript on power pages

Like (0) ShareShare
ReportReport
Posted on 21 Oct 2024 09:59:11 by
I have a choices / multi-select field on power page, where an user can select 1 or more values. the values are Title, first name, last name, age. Based on these list of values, I would want to show the respective field using the custom javascript on power pages.
 
Please let me know how do I check / get the list of selected values from a choices / multi-select control.
 
Thanks in advance.
Categories:
  • Suggested answer
    SaiRT14 Profile Picture
    1,966 Super User 2025 Season 1 on 22 Oct 2024 at 00:31:42
    Check/get selected options from a 'Choices' field using custom Javascript on power pages

    Pls try the following it will fix.

    • Access the Multi-Select Control: First, make sure the multi-select field has a unique ID or class that you can target with JavaScript.

    • Get the Selected Values: Use JavaScript to retrieve the selected values from the multi-select field. In Power Pages, the multi-select field stores values as an array, so you can loop th rough the selected options.

    • Check Which Fields are Selected:You can use the .map() or .forEach() method in JavaScript to get the selected values and then determine which fields to show based on the user’s selection.

    • Show/Hide Fields Based on Selection: Use JavaScript to show or hide the corresponding fields based on the values selected by the user.

  • Suggested answer
    Fubar Profile Picture
    7,846 Super User 2025 Season 1 on 21 Oct 2024 at 22:21:42
    Check/get selected options from a 'Choices' field using custom Javascript on power pages
    This post by Oliver Rodriguez contains a number of pieces of JavaScript for working with multiselect choices

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,670 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,004 Most Valuable Professional

Leaderboard
Loading started