Page 1 of 1
Display the sum of two id's amount of clicks?
Posted: Sat Sep 29, 2012 7:37 am
by MClick
Version of script: 1.2
Hi, displaying number of clicks works fine and all that. But I'm trying to find a solution to add the sum of clicks of one id with the sum of clicks of an other id and then display the total.
Basically if id 1 has 10 clicks and id 2 has 5 clicks I want to display 15 (id1+id2) as the total.
Is this possible?
I've tried different solutions in the manners of:
<script language="Javascript">ccount_display('1')+('2')</script>
But that was obviously too simple
Thanks in advance!
Re: Display the sum of two id's amount of clicks?
Posted: Sat Sep 29, 2012 3:48 pm
by Klemen
In display.php if you find
Code: Select all
function ccount_display(id) {
document.write(ccount_link[id]);
}
and paste this below:
Code: Select all
function ccount_sum(id1, id2) {
var sum = ccount_link[id1] + ccount_link[id2];
document.write(sum);
}
You could then use
Code: Select all
<script language="Javascript">ccount_sum('1', '2')</script>
Re: Display the sum of two id's amount of clicks?
Posted: Sun Sep 30, 2012 6:37 am
by MClick
Klemen wrote:...brilliant solution...
That worked perfectly, thank you so much! And thank you for such a quick response.
Re: Display the sum of two id's amount of clicks?
Posted: Thu Jan 28, 2016 7:14 pm
by robsterling
Is there a current version of this script available? It looks like this is for an older version of CCount.
Re: Display the sum of two id's amount of clicks?
Posted: Thu Jan 28, 2016 8:23 pm
by robsterling
I tried rewriting it like this, but it doesn't work.
Code: Select all
function ccount_sum (id1, id2, id3, id4, id5)
{
var sum = ccount[id1]['c'] + ccount[id2]['c'] + ccount[id3]['c'] + ccount[id4]['c'] + ccount[id5]['c'];
document.write(sum).formatThousands('<?php echo $ccount_settings['notation']; ?>'));
}
Re: Display the sum of two id's amount of clicks?
Posted: Sat Jan 30, 2016 12:13 pm
by Klemen
This should do the trick in 2.x:
Code: Select all
function ccount_sum(id1, id2)
{
var sum = ccount[id1]['c'] + ccount[id2]['c'];
document.write(sum.formatThousands('<?php echo $ccount_settings['notation']; ?>'));
}
Then to display:
Code: Select all
<script>ccount_sum('1', '2')</script>
Re: Display the sum of two id's amount of clicks?
Posted: Mon Feb 01, 2016 3:51 pm
by robsterling
That works. Thanks, man.
Re: Display the sum of two id's amount of clicks?
Posted: Wed Feb 10, 2016 7:12 pm
by Klemen
This feature (and some additional display options) has been included in version 2.1.0 that has been released just now.