The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Need help with Replies Count Javascript

4 posters

Go down

Solved Need help with Replies Count Javascript

Post by Van-Helsing June 13th 2014, 10:58 am

Hi all,
I am facing a problem with a javascript which it counts the number of replies in a post:

Code:

$(function(){
         var p = $('.main-head p.h2')[0];
         var paging = $('p.paging');
         var nf = $('.posthead').last().find('h2 strong').text().match(/\d+/g)-1;
         var link =  $('p.paging').not('img').find('a:last').attr('href');
        if(!paging) {
            $(p).replaceWith('<span class="countpost">'+nf+'</span>');
        }else if(paging) {
         $.get(link, function(data) {
            var nl = $('.posthead:last', data).find('h2 strong').text().match(/\d+/g)-1;
            $(p).replaceWith('<span class="countpost">'+nl+'</span>');
         });
        }
        });

This script it doesn't return the number of replies it returns the false value - 1 http://prntscr.com/3sce8m , furthermore I am facing and another problem that I can move the text of this script a little right because its covering the the basic/regular view buttons http://prntscr.com/3sceix .


Last edited by Dark-Avenger on July 7th 2014, 9:01 pm; edited 2 times in total
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Van-Helsing June 15th 2014, 1:37 am

Bump
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Van-Helsing June 16th 2014, 2:37 am

Bump
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Van-Helsing June 18th 2014, 2:06 pm

bump
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by SSYT June 19th 2014, 11:16 am

What is your forum link ?
SSYT
SSYT
Forumember

Male Posts : 77
Reputation : 15
Language : RO-10, EN-3, FR-1
Location : Romania

http://help.forumgratuit.ro/forum

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Van-Helsing June 19th 2014, 2:05 pm

Hello my forum link is:

Spoiler:
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by SSYT June 19th 2014, 4:18 pm

Try new Smile
Code:
$(function(){
    var p = $('.main-head')[0];
    var paging = $('p.paging');
    var nf = $('.post_id').last().find('.post_number').text().match(/\d+/g)-1;
    var link =  $('p.paging').not('img').find('a:last').attr('href');
    if(!paging) {
        $(p).prepend('<span class="countpost">'+nf+'</span>');
    }
   else if(paging) {
        $.get(link, function(data) {
            var nl = $('.post_id').last().find('.post_number').text().match(/\d+/g)-1;
            $('.countpost', p).html(nl);
        });
    }
});
SSYT
SSYT
Forumember

Male Posts : 77
Reputation : 15
Language : RO-10, EN-3, FR-1
Location : Romania

http://help.forumgratuit.ro/forum

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Van-Helsing June 19th 2014, 11:13 pm

Hi Inferno,
I tried your code but it didn't work and I have modify the javascript into this code

Spoiler:

and now its displaying the replies number with the text but the replaceWith function covers the Basic/Regular View Javascript's buttons. Is there another function instead the replaceWith to fix the problem.

Before adding the Count Post Javascript : http://prntscr.com/3uk6yp
After adding the Post Count Javascript   : http://prntscr.com/3uk62t

Is there a way to fix it? Something is going wrong with this function.

Best Regards,
Dark-Avenger
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by SSYT June 20th 2014, 8:50 am

Try new Smile
Code:
$(function(){
    var p = $('.main-head')[0];
    var paging = $('p.paging');
    var nf = $('.post_id').last().find('.post_number').text().match(/\d+/g)-1;
    var link =  $('p.paging').not('img').find('a:last').attr('href');
    if(!paging) {
        $(p).prepend('<span class="countpost">'+nf+' reply this topic</span>');
    }
  else if(paging) {
        $.get(link, function(data) {
            var nl = $('.post_id').last().find('.post_number').text().match(/\d+/g)-1;
            $('.countpost', p).html(nl+' reply this topic');
        });
    }
});

And CSS:
Code:
.countpost{
float: right;
}
[/code]

Not edit the codes Smile
SSYT
SSYT
Forumember

Male Posts : 77
Reputation : 15
Language : RO-10, EN-3, FR-1
Location : Romania

http://help.forumgratuit.ro/forum

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Van-Helsing June 20th 2014, 9:05 am

Hi Inferno,
I have substitute the codes but they aren't working http://prntscr.com/3un8pv they dont display anything in the right side of the titlebar. Sad
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Van-Helsing June 21st 2014, 10:51 am

Bump
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Van-Helsing June 22nd 2014, 12:09 pm

Bump
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Van-Helsing June 23rd 2014, 1:02 pm

Bump
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Van-Helsing June 24th 2014, 1:05 pm

Bump
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Van-Helsing June 25th 2014, 2:07 pm

Bump
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Van-Helsing June 26th 2014, 2:27 pm

Bump
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Van-Helsing June 27th 2014, 2:28 pm

Bump
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Van-Helsing June 28th 2014, 8:15 pm

Bump
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Van-Helsing June 30th 2014, 2:34 pm

Bump
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Van-Helsing July 2nd 2014, 12:18 am

Bump
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Van-Helsing July 4th 2014, 12:27 am

Bump
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Van-Helsing July 5th 2014, 1:47 am

Bump
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Van-Helsing July 6th 2014, 2:17 am

Bump
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Van-Helsing July 7th 2014, 10:58 am

Bump
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Ange Tuteur July 7th 2014, 12:02 pm

Hi,

Try this :
Code:
$(function(){
        var p = $('.main-head p.h2')[0];
        var paging = $('p.paging');
        var nf = $('.post_number').text().match(/\d+/g)-1;
        var link =  $('p.paging').not('img').find('a:last').attr('href');
        if(!paging) {
            $(p).after('<span class="countpost">'+nf+'</span>');
        }else if(paging) {
        $.get(link, function(data) {
            var nl = $('.post_number:last', data).text().match(/\d+/g)-1;
            $(p).after('<span class="countpost">'+nl+'</span>');
        });
        }
        });
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Van-Helsing July 7th 2014, 3:17 pm

Hello Ange Very Happy ,
Its working but I can't decrease the space between the number of posts and the text now its displaying like this http://prntscr.com/4092ap

Best Regards,
Dark-Avenger
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Ange Tuteur July 7th 2014, 5:03 pm

In your CSS stylesheet is this Rule :
Code:
.countpost:after {
    content: " Απαντήσεις σε αυτό το θέμα";
    margin-left: 150px;
}

Decrease the value of margin-left to decrease the size of the gap.
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13207
Reputation : 3000
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by Van-Helsing July 7th 2014, 9:00 pm

Thank you very much. Its solved.
Van-Helsing
Van-Helsing
Hyperactive

Male Posts : 2431
Reputation : 116
Language : English, Greek

http://itexperts.forumgreek.com/

Back to top Go down

Solved Re: Need help with Replies Count Javascript

Post by SLGray July 7th 2014, 9:08 pm

Topic Solved & Archived


Need help with Replies Count Javascript Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51583
Reputation : 3526
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum