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
Shruthi MN 32Shruthi MN 32 

LWC Help

I have written a code to calculate SI but each time I try to add calculate any value I am getting below error

User-added image
Danish HodaDanish Hoda
You might be getting some value as undefined. Please share your code
Akash KainturaAkash Kaintura
Is the Actions is called when initiating from the controller/Apex class.
Shruthi MN 32Shruthi MN 32

Below is the HTML code


<template>
    <lightning-card title="Simple Interest Cal"></lightning-card>
   
        <lightning-layout multiple-rows></lightning-layout>
            <lightning-layout-item size= "12" padding = "around-medium" > </lightning-layout-item>
<lightning-input type="number" label = "Enter Principle" onchange= {principalChangeHandler}>
    </lightning-input>
   
    <lightning-layout-item size= "12" padding = "around-medium" > </lightning-layout-item>
    <lightning-input type="numer" label = "Enter No Of Years" onchange= {timechangehandler}>
    </lightning-input>
   
    <lightning-layout-item size= "12" padding = "around-medium" > </lightning-layout-item>
    <lightning-input type="number" label = "Enter Rate Of Interest" onchange= {ratechangehandler}>
    </lightning-input>
   
    <lightning-layout-item size= "12" padding = "around-medium" ></lightning-layout-item>
    <lightning-button label= "Calculate SI" icon-position = "centre" onclick= {calculateSIHandler} >

    </lightning-button>


<lightning-layout-item size= "12" padding = "around-medium" > </lightning-layout-item>
    <lightning-formatted-text value= {currentoutput}  ></lightning-formatted-text>
   

       
</template>


JS

import  { LightningElement, track } from 'lwc';

export default class Simpleinterstcal extends LightningElement {
   
@track currentOutput;
principal;
rateofinterest;
noOfyears;

principalChangeHandler (event)
{
this.principal = parseInt(event.target.value,10);
}
timechangehandler (event)
{
this.noOfyears = parseInt(event.target.value,10);
}
ratechangehandler (event)
{
this.rateofinterest = parseInt(event.target.value,10);
}
calculateSIHandler()
{
this.currentOutput =  'Simple Interest is :' +parseFloat((this.principal*this.rateofinterest*this.noOfyears)/100);
}
}


XML

<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>48.0</apiVersion>
    <isExposed>true</isExposed>
<targets>
<target>lightning__AppPage</target>
<target>lightning__RecordPage</target>
<target>lightning__HomePage</target>
</targets>
</LightningComponentBundle>


Attached is the snip of the error
 
Danish HodaDanish Hoda
Hi Shruthi,
I have checked your code and its running in my org without any error, please check the API version of your org, might be that 48.0 is not currently supported