You need to sign in to do that
Don't have an account?
Herish Surendran
I am working in LWC and facing an issue.
A table in componentName.html
componentName.js
When the select method executes, the value of selectedMethod property becomes Phone-57 instead of Phone.
So I changed the function to
Can anyone please tell why this is happening.
<table style="border-collapse: collapse; width: 100%;"> <tr> <td style="border: 1px solid grey; text-align: left; padding: 8px;"> <input type="radio" id="Phone" name="verificationMethod" value={phone} onchange={selectMethod}/> <label class="slds-text-heading_small"> {phone}</label> </td> </tr> </table>
componentName.js
selectMethod(event){ this.selectedMethod = event.target.id; }
When the select method executes, the value of selectedMethod property becomes Phone-57 instead of Phone.
So I changed the function to
selectMethod(event){ this.selectedMethod = event.target.id.replace('-57',''); }
Can anyone please tell why this is happening.
Why you Assign the this.selectMethod to value? it should be Variable which you want to display in the HTML Table.
Hope below You are Expecting? if any let me know
LWC HTML:
<template>
<lightning-input value ="Phone" type="radio" onchange={handleChange} label="Enter a fruit name"></lightning-input>
{Newphone}
</template>
LWC JS :
export default class App extends LightningElement {
phone;
Newphone;
handleChange(event) {
this.phone = event.target.value;
this.Newphone = this.phone + " - 57";
console.log(this.Newphone );
}
}