Simple Apex class to perform addition and subtraction based on the button u have clicked.
Public class Example
{
public Integer bvalue{get;set;}
public Integer avalue{get;set;}
Public integer result{get;set;}
Public String operation{get;set;}
public pageReference subb()
{
rsult='Subtraction';
return null;
}
Public pageReference add()
{
result=avalue+bvalue;
operation='Addition';
return null;
}
}
<apex:page controller="Example">
<apex:form>
<apex:pageBlock title="calculatior">
<apex:pageBlockSection columns="1" title="simple operations" collapsible="false">
<apex:pageBlockSectiomItem>
<apex:outputLabel> Enter A value</apex:outputLabel>
<apex;inputText value="{!avalue}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectiomItem>
<apex:outputLabel> Enter B value </apex:outputLabel>
<apex;inputText value="{!bvalue}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectiomItem>
<apex:outputLabel>you have performed{!operation} of {!avalue} and {!bvalue} and result is {!result} </apex:outputLabel>
</apex:pageBlockSectionItem>
<apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
No comments:
Post a Comment