Skip to main content

Notifications

Power Pages - General Discussions
Suggested answer

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

Posted on 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
    SaiRT14 317 on at
    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
    Fubar 7,458 on at
    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

September 2024 Newsletter…

September 2024 Community Newsletter…

Community Update Sept 16…

Power Platform Community Update…

Tuesday Tip #2 Global Search…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 142,008

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,531

Leaderboard

Featured topics