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
divya sri 31divya sri 31 

how to calculate a number of clicks on a button in visualforce page

Hi All,
i am working on a project where i have a field in my model called count 
in my visualforce page if user clicks on a command link then that count must go a set in my model 
I have to get the total number of counts in the model 
can any one help with this (simple code)

thank u in advs 
 
Raj VakatiRaj Vakati
Refer this links

https://developer.salesforce.com/forums/?id=906F0000000BQ69IAG

https://salesforce.stackexchange.com/questions/126128/run-javascript-when-clicking-button-on-vf-page


code
 
<apex:page showHeader="false" controller="IncrementCtrl">
<apex:form >
	Number : {!numb}
	<apex:commandButton value="Click" action="{!display}"/>
</apex:form>
</apex:page>
 
public class IncrementCtrl{

    public Integer numb{get;set;}
	
	public void IncrementCtrl(){
		numb = 100;
	}
    public void display(){
		numb = numb + 1;
    }

}

 
Ajay K DubediAjay K Dubedi
Hi Divya,

Try this code:

Vf page:
<apex:page controller="Buttonclick_controller">
    <apex:form> 
        <apex:pageBlock>
            <apex:commandButton value="click" action="{!countclick}"/> <br/>
                  Number of clicks= {!countvalue}
        </apex:pageBlock>
    </apex:form> 
</apex:page>

Controller class:
public class Buttonclick_controller {
public Integer count{get;set;}
public Integer countvalue{get;set;}
public Buttonclick_controller()
{
    count=1;
}
public void countclick()
{
   countvalue=count++; 
}
}

Hope this code will help you.Mark it as best answer so that others get help from this too.
Thanks.
Ajay Dubedi
divya sri 31divya sri 31
thank u all for ur rly 
i will try and come back