I have an idea for a script that I was hoping someone at the js forum could help me start or write a basic version of because i have no clue where to start it.
So what I am trying to accomplish is counting how many times a div (if necessary it can be a <button> or <input />) has been clicked and then displaying it. The counting meaning numbers of times clicked so that would have to be stored in a variable and then if the user clicks that number or variable is incremented by one.
Is this possible to do in js and if so can someone please help me start writing this ?
I would really appreciate any and all help with this
Thanks in Advance & Best Regards,
Have a look at the following jsFiddle which i created a simple demo in, basically it just creates a new element after the target element and increments the count with each click.
hmm cool! that was exactly what i was looking for. :weee: thank you very much!
Do you know how one could limit the user to only clicking once? like a voting system?
If you only need the button to be clicked once then a counter isn't even needed, see the below jsFiddle which makes use of the element object to detect if it has been clicked.
hmm okay, but why get rid of the counter
I was thinking of something that counts how many different people / computers voted or clicked the button. sorry if i was confusing before
no it wouldn't. But then people could alter the vote by clicking countlessly. so would PHP need to be involved then?
do you know how one would check with the server to see if the user has voted and if they have then show the button and the total votes, but do not allow there votes to count; and, if they havent voted allow there one vote to count?
could that be done in PHP or Perl?
This topic is now closed. New replies are no longer allowed.