You need to sign in to do that
Don't have an account?
Sankar Ganesh
Addition in visualforce
Since I am a I have some struggle.
I have to get two numbers and my labels for that is value1 and value2.I have another button called submit when I press that I should get sum.
How should I get a sum here.
My Apex code of two numbers
public class Sample{
public Integer userinput{ get;set;}
public Integer userinput1{ get;set;}
public Integer sum(){
Integer c=userinput+userinput1;
return c;
}
public pageReference getsum()
{
sum();
return null;
}
}
My visualforce page
<apex:page controller="Sample" >
<apex:form >
<apex:pageBlock >
<apex:outputLabel >Value1</apex:outputLabel>
<apex:inputText value="{!userinput}"/> <br/><br/>
<apex:outputLabel >Value2</apex:outputLabel>
<apex:inputText value="{!userinput1}"/>
<apex:commandButton value="submit" action="{!getsum}"/><br/><br/>
<apex:outputLabel >sum</apex:outputLabel>
<apex:outputField value="{}" />
</apex:pageBlock>
</apex:form>
</apex:page>
I have to get two numbers and my labels for that is value1 and value2.I have another button called submit when I press that I should get sum.
How should I get a sum here.
My Apex code of two numbers
public class Sample{
public Integer userinput{ get;set;}
public Integer userinput1{ get;set;}
public Integer sum(){
Integer c=userinput+userinput1;
return c;
}
public pageReference getsum()
{
sum();
return null;
}
}
My visualforce page
<apex:page controller="Sample" >
<apex:form >
<apex:pageBlock >
<apex:outputLabel >Value1</apex:outputLabel>
<apex:inputText value="{!userinput}"/> <br/><br/>
<apex:outputLabel >Value2</apex:outputLabel>
<apex:inputText value="{!userinput1}"/>
<apex:commandButton value="submit" action="{!getsum}"/><br/><br/>
<apex:outputLabel >sum</apex:outputLabel>
<apex:outputField value="{}" />
</apex:pageBlock>
</apex:form>
</apex:page>
- Add re-render attribute to the button (Optional)
Hope this helps