Page 1 of 1

i need code for count number of times clicked the button

Posted: Sat Nov 11, 2006 2:57 am
by qumar
hi,
i need code for count number of times clicked the button. Please help to me.

Thanks.

Posted: Sat Nov 11, 2006 4:12 am
by timvw
The button (if any) would be displayed at the client-side and thus it's impossible to handle that event at the server-side...

Now, if you made sure that the button click would lead to a http post/get requrest... then you could handle that request..

The logic for a counter is pretty simple: new value = old value + 1. So i wonder, what exactly are you having problems with?

Re: i need code for count number of times clicked the button

Posted: Sat Nov 11, 2006 2:23 pm
by califdon
qumar wrote:hi,
i need code for count number of times clicked the button. Please help to me.

Thanks.
You may want to do this in Javascript, which executes in the browser, where the button is being clicked. PHP is interpreted by the server BEFORE anything is sent to the browser.

Posted: Sat Nov 11, 2006 3:57 pm
by aaronhall
timvw wrote:The button (if any) would be displayed at the client-side and thus it's impossible to handle that event at the server-side...
Ajax is pretty cool, though

Re: i need code for count number of times clicked the button

Posted: Sat Nov 11, 2006 8:24 pm
by Cameri
califdon wrote:
qumar wrote:hi,
i need code for count number of times clicked the button. Please help to me.

Thanks.
You may want to do this in Javascript, which executes in the browser, where the button is being clicked. PHP is interpreted by the server BEFORE anything is sent to the browser.
Through the use of AJAX techniques, you can handle data back and forth between Javascript and PHP.
If what you are trying to accomplish can be done client-side, that is, it does not need any manipulation from the server, you can just leave it with Javascript, if not, you'll have to fly into the magical world of AJAX.

What is it that you are trying to do?

Posted: Sun Nov 12, 2006 7:09 am
by bokehman
Why don't you just disable the button after it has been clicked.

Posted: Mon Nov 13, 2006 1:08 am
by RobertGonzalez
If this is for security in form processing prevention, I would suggest a dual-validation format where you use Javascript on the client and PHP on the server. I'd do it this way because 1) some users disable javascript in their browsers which renders client side validation moot, and 2) it is possible to download your form to their local machine, manipulate it to be what they want and submit it. If it is not checked on the server, you could be hosed.