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
Vishwas B NVishwas B N 

How to capture value form the clicked element

i have created component which display 3 product  family name. i want to capture the value of the product which is been clicked. Below are my Code

ProductCatalogPage.html---
<template>
    <div class="slds-grid slds-gutter">
        <template for:each={getmyProducts.data} for:item="product" for:index='itemindex'>
            <div class="slds-col slds-size_1-of-3 family" key={product.id}>
                <lightning-card data-name={product.name} onclick={handleSelectItem}>
                    <div class="slds-align_absolute-center"><img src={product.Image_Url__c} class="product"
                                alt={product.Name} /></div>
                    <p class="slds-align_absolute-center heading">{product.Name}</p>
                </lightning-card>
            </div>
        </template>
    </div>
</template>

ProductCatalogPage.js
import { LightningElement, wire ,api, track} from 'lwc';

import getProductFamily from '@salesforce/apex/ProductFamilyController.getProductFamily';

export default class ProductCatalogPage extends LightningElement {

    searchKey = '';
    @wire(getProductFamily, { searchKey: '$searchKey' })
    getmyProducts;
    handleSelectItem(event){
       alert(event.target.dataset.name);
    }
}



But when i select the product i get "undefined " in the alert please help.





 
Best Answer chosen by Vishwas B N
SwethaSwetha (Salesforce Developers) 
HI Vishwas,
The link https://developer.salesforce.com/docs/component-library/tools/playground/QWa-zfwxW/60/edit has code for fetching the selected radio button. You might want to customize it according to your requirement

Thanks