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
Hiral Patel 25Hiral Patel 25 

create a calculator using aura id

create a calculator using aura id
VinayVinay (Salesforce Developers) 
Hi Hiral,

Check below references that has details on creating calulator using lightning components.

https://www.biswajeetsamal.com/blog/simple-calculator-using-salesforce-lightning-components/
https://developer.salesforce.com/forums/?id=9062I000000ILWbQAO

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
Sameer Kulkarni 14Sameer Kulkarni 14
Hi Hiral , 

You can take refernce of below example for creating calculator using Aura:Id . Mark me / Hit like if i solved your query .
let me know if you face any issue .

Component File : 


<aura:component > 
    <lightning:input Aura:id="Sam1" name="Firstname" label="Enter first Number" placeholder="type here..."/>
    <br/>
    <lightning:input Aura:id="Sam2" name="secondname" label="Enter second Number" placeholder="type here..."/>
    <aura:attribute name="Myresult" type="Integer" />
    <br/>
    <lightning:button variant="brand" label="Addition" title="Brand action" onclick="{! c.handleClick }" />
    <lightning:button variant="brand" label="substraction" title="Brand action" onclick="{! c.handleClick }" />
    <lightning:button variant="brand" label="multiplication" title="Brand action" onclick="{! c.handleClick }" />
    <br/>
    <br/>
    Result is = {!v.Myresult}  . 
</aura:component>


JS File :

({
    handleClick : function(component, event, helper) {
        var fname = parseInt(component.find("Sam1").get("v.value"));
        var sname = parseInt(component.find("Sam2").get("v.value"));
        var result = 0 ;
        var buttonclick = event.getSource().get("v.label");
        if(buttonclick === "Addition"){
             var result = fname + sname ;
          component.set("v.Myresult",result);
        }else if (buttonclick === "substraction"){
              var result = fname - sname ;
          component.set("v.Myresult",result);
        }else if  (buttonclick === "multiplication"){
            var result = fname * sname ;
          component.set("v.Myresult",result);
    }
    }
})