function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Abilash.SAbilash.S 

Based on picklist value, stars should represent

I have customer feedback object. When I select picklist values of  1,2,3,4,5. Automatically stars should represent. If I select 3 from picklist, 3 stars need to display. Based on picklist values stars should display. How could I accomplish this.
Danish HodaDanish Hoda
hi Abhilash,
If you are using a lightning cmp (Aura/LWC), you can add 
<lightning:icon iconName="utility:rating" />
inside a loop to show rating icons per the picklist val selected
Abilash.SAbilash.S
Thank you Danish, could you explain in brief and provide some related links.
Danish HodaDanish Hoda
Hi Abhilash,
PFB the code snippet developed on LWC - 
HTML : 
<lightning-card>
        <lightning-layout >
            <div class="slds-size_2-of-3">
                        <lightning-combobox
                                name="rating"
                                variant="label-hidden"
                                value={value}
                                placeholder="Kindly provide a rating"
                                options={options}
                                onchange={handleChange} >
                        </lightning-combobox>

                    </div>
                    <div class="slds-size_1-of-3">
                        <template for:each={ratings} for:item="val">
                            <lightning-icon key={val} icon-name="utility:rating" ></lightning-icon>
                        </template>
                    </div>
        </lightning-layout>
    </lightning-card>

JS : 
value = '';
    ratings = [];

    get options() {
        return [
            { label: '1', value: '1' },
            { label: '2', value: '2' },
            { label: '3', value: '3' },
            { label: '4', value: '4' },
            { label: '5', value: '5' },
        ];
    }

    handleChange(event) {
        this.value = event.detail.value;
        let valInt = parseInt(this.value);
        this.ratings = [];
        for(let i=0; i<valInt; i++){
            this.ratings.push(i);
        }
    }

User-added imageUser-added image