• Rafat89778
  • NEWBIE
  • 0 Points
  • Member since 2021

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I am trying to built a age calculator. calculator take input from calendar and output age. but this program don't show anything.

Agecalculator.html
<template>
    <lightning-card  title="Age Calculator">
        <lightning-button variant="brand" label="Calculate"  slot="actions" onclick={calculateDOB}></lightning-button>
        <p class="slds-p-horizontal_small">
            <lightning-input type="date" name="BirthDate" label="Enter Your Date Of Birth" placeholder="type here..." value={birthdate} onchange= {handleChangeNum1}></lightning-input>
            result---{result}
        </p>
    </lightning-card>
</template>
AgeCalculator.js
export default class AgeCalculator extends LightningElement {
    @track result;
    @track birthdate;
    today = new Date();


    handleChangeNum1(event){
        const inpurdate = event.target.name;
        const inputvalue= event.target.value;
        if(inpurdate=='BirthDate'){
            this.birthdate=inputvalue;
        }

    }
    calculateDOB (event) {

        this.result=today.getfullyear-this.birthdate.getfullyear;
    }
}


 
I am trying to built a age calculator. calculator take input from calendar and output age. but this program don't show anything.

Agecalculator.html
<template>
    <lightning-card  title="Age Calculator">
        <lightning-button variant="brand" label="Calculate"  slot="actions" onclick={calculateDOB}></lightning-button>
        <p class="slds-p-horizontal_small">
            <lightning-input type="date" name="BirthDate" label="Enter Your Date Of Birth" placeholder="type here..." value={birthdate} onchange= {handleChangeNum1}></lightning-input>
            result---{result}
        </p>
    </lightning-card>
</template>
AgeCalculator.js
export default class AgeCalculator extends LightningElement {
    @track result;
    @track birthdate;
    today = new Date();


    handleChangeNum1(event){
        const inpurdate = event.target.name;
        const inputvalue= event.target.value;
        if(inpurdate=='BirthDate'){
            this.birthdate=inputvalue;
        }

    }
    calculateDOB (event) {

        this.result=today.getfullyear-this.birthdate.getfullyear;
    }
}