You need to sign in to do that
Don't have an account?

increment the value when button is clicked
Hi all,
When ever the button "Click" is clicked. The value should increment to 0,1,2,3,4,...etc,. Should not use JavaScript. Use only controller and vf page.
I have tried but, no value is incrementing. Once go through the below code.
VF Code:
Apex Class:
What is wrong in my code?
When ever the button "Click" is clicked. The value should increment to 0,1,2,3,4,...etc,. Should not use JavaScript. Use only controller and vf page.
I have tried but, no value is incrementing. Once go through the below code.
VF Code:
<apex:page showHeader="false" controller="increment"> <apex:form > <apex:commandButton value="Click" action="{!display}"/> </apex:form> </apex:page>
Apex Class:
public class increment{ integer numb; integer i; public void display(){ numb = 100; for(i=0; i<numb; i++){ i=i+1; System.debug(i); } } }
What is wrong in my code?
Please follow the below url.
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_actionSupport.htm
Regards,
Sai Krishna Tavva.
You are already incrementing value of 'i' in for loop, there is no need to increment again.
Please find below revised code and let me know if that helps you.
Best Regards,
BALAJI
VF Page:
Controller:
Best Regards,
BALAJI
Does this solve your question ?
Best Regards,
BALAJI
Controller :