You need to sign in to do that
Don't have an account?
Shuhbam Sinha
const temp = this.template.querySelectorAll("lightning-input-field[data-id= '0069I000003OWmc']");
Please help me on the same. Thanks in advance
How to pass dynamic id to 'querySelectorAll' in lwc
Hello Everyone,
I need to pass dynamic data -id to this.template.querySelectorAll("lightning-input-field[data-id= 'accountId']");
for (let i = 0; i < this.accounts.length; i++) { var accountId = this.accounts[i].Id; const temp = this.template.querySelectorAll("lightning-input-field[data-id= 'accountId']"); console.log('temp',temp[2]); temp[2].value = dateToday.toJSON().slice(0, 10); } // var accountId is not working hereaccountId is not working here but if i pass hard coded id like
const temp = this.template.querySelectorAll("lightning-input-field[data-id= '0069I000003OWmc']");
html <lightning-input-field field-name="Year_Months_To__c" variant= "label-hidden" data-id={acc.Id} value={yearsMonthsTo} onchange={handleDateTo} required> </lightning-input-field>
Please help me on the same. Thanks in advance
Hi Shubham,
You can refer to below code.
If you want to use accountId dynamically, use template literals.
Please mark it as best answer if it helps.
Thanks,
All Answers
Please refer to the following Stack Exchange link which has the same issue, This might help you achieve your requirement.
https://salesforce.stackexchange.com/questions/256007/how-do-you-define-an-element-with-an-id-attribute-using-lwc
Related:-
https://developer.salesforce.com/forums/?id=9062I000000UhWfQAK (http://https://developer.salesforce.com/forums/?id=9062I000000UhWfQAK)
Please mark it as Best Answer if the above information was helpful.
Thanks.
Hi Shubham,
You can refer to below code.
If you want to use accountId dynamically, use template literals.
Please mark it as best answer if it helps.
Thanks,