I want to use a dynamic value inside querySelectorAll method but unable to use it.
let Product= event.target.dataset.item;
alert(Product);
let checkboxes = this.template.querySelectorAll('[data-id="${Product}"]');
The above mentioned code is not working because it is not able to comprehend the value of product inside. **The alert is providing the correct value so the variable has correct data.
On hardcoding the value of the product its working fine
let Product= event.target.dataset.item;
alert(Product);
let checkboxes = this.template.querySelectorAll('[data-id="OpenEdge"]');
added HTML:
<div class="slds-col slds-size_1-of-5 slds-align_absolute-center">
<span>
<lightning-input class="slds-p-left_xx-large" type="checkbox" label="" data-item={product.MasterLabel} onchange={handleChange}>
</lightning-input>
</span>
</div>
<div class="slds-col slds-size_1-of-5 slds-align_absolute-center">
<template if:true={product.Product_Alerts__c}>
<span>
<lightning-input class="slds-p-left_xx-large" type="checkbox" data-id="{product.MasterLabel}"></lightning-input>
<lightning-input class="slds-p-left_xx-large" type="checkbox" data-id={product.MasterLabel} ></lightning-input>
</span>
</template>
</div>
Is there any other way of using variable inside the method?