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.

Problems getting a javascript working on forum

5 posters

Go down

Solved Problems getting a javascript working on forum

Post by VDimensional January 7th 2025, 11:54 am

I was trying to set it up so I could have automatic polls for a few of the product review categories in my forum using the 2nd javascript from this topic https://help.forumotion.com/t143063-how-can-i-add-an-automatic-poll-like-here-on-the-support-forum
However despite making sure the forum id's are correct and javascript code management is enabled in the control panel when a new post is posted in said forums/categories it does not automatically create the poll
I am using awesomebb for the forum

what I'm trying to use:
Code:
        window.location.pathname == '/post' && $(function () {
          var forums = [24, 25],
       
          lang = {
            info : 'The poll will be added automatically.',
            poll_question : 'Arvosana',
            poll_answers : '1\n2\n3\n4\n5'
          },
       
          i = 0,
          j = forums.length,
          f;
       
          if (document.post && document.post.mode.value == 'newtopic') {
            f = document.post.f.value;
         
            for (; i < j; i++) {
              if (f == forums[i]) {
                $(document.post.poll_title).closest('fieldset').html('<strong>' + lang.info + '</strong><input type="hidden" name="poll_title" value="' + lang.poll_question + '" /><input type="hidden" name="poll_option_text" value="' + lang.poll_answers + '"><input type="hidden" name="poll_length" value="0" /><input type="hidden" name="poll_cancel_vote" value="1" />');
                break;
              }
            }
          }
        });


Last edited by VDimensional on January 9th 2025, 2:13 pm; edited 1 time in total
VDimensional
VDimensional
New Member

Posts : 11
Reputation : 1
Language : Finnish

Back to top Go down

Solved Re: Problems getting a javascript working on forum

Post by skouliki January 7th 2025, 12:02 pm

hello

this script is created for version PHPBB3
each version has different elements so this is way this script is not working on your forum
skouliki
skouliki
Manager
Manager

Female Posts : 15475
Reputation : 1710
Language : English,Greek
Location : Greece

http://iconskouliki.forumgreek.com

Back to top Go down

Solved Re: Problems getting a javascript working on forum

Post by VDimensional January 7th 2025, 12:08 pm

skouliki wrote:hello

this script is created for version PHPBB3
each version has different elements so this is way this script is not working on your forum

Good to know. How would I modify the script to work with AwesomeBB? I'm not too familiar with this script stuff
VDimensional
VDimensional
New Member

Posts : 11
Reputation : 1
Language : Finnish

Back to top Go down

Solved Re: Problems getting a javascript working on forum

Post by Ape January 7th 2025, 3:35 pm

Sadly the maker of the script is no longer using the forum so unless @Razor12345 or @Niko can try and make this work for you then I'm sorry we can't help you.

Sadly that code is a little old now and was not made to work for other forums.


Problems getting a javascript working on forum Left1212Problems getting a javascript working on forum Center11Problems getting a javascript working on forum Right112
Problems getting a javascript working on forum Ape_b110
Problems getting a javascript working on forum Ape1010
Ape
Ape
Administrator
Administrator

Male Posts : 19525
Reputation : 2018
Language : fluent in dork / mumbojumbo & English haha

http://chatworld.forumotion.co.uk/

Niko likes this post

Back to top Go down

Solved Re: Problems getting a javascript working on forum

Post by VDimensional January 7th 2025, 4:07 pm

Ape wrote:Sadly the maker of the script is no longer using the forum so unless @Razor12345 or @Niko can try and make this work for you then I'm sorry we can't help you.

Sadly that code is a little old now and was not made to work for other forums.

I see. Would there be any other methods to implement such product review functionality? A star based rating system would be ideal for such application but I've had little luck in finding a solution. I understand though if such a feature is not possible to easily implement 😅
VDimensional
VDimensional
New Member

Posts : 11
Reputation : 1
Language : Finnish

Back to top Go down

Solved Re: Problems getting a javascript working on forum

Post by Niko January 7th 2025, 8:16 pm

@VDimensional no idea if there could be another way, it's probably something that is worth a suggestion Wink

If instead you want to adapt the code to AwesomeBB version, could you give me your preference for all these settings?
  • Poll question
  • Poll options
  • Vote cancelling allowed
  • Display the list of members who voted
  • Display the list of members who voted for each choice
Niko
Niko
Helper
Helper

Male Posts : 3354
Reputation : 261
Language : English, Italian, French
Location : Italy

https://www.fmcodes.net/

Back to top Go down

Solved Re: Problems getting a javascript working on forum

Post by VDimensional January 7th 2025, 8:41 pm

Niko wrote:@VDimensional no idea if there could be another way, it's probably something that is worth a suggestion Wink

If instead you want to adapt the code to AwesomeBB version, could you give me your preference for all these settings?
  • Poll question
  • Poll options
  • Vote cancelling allowed
  • Display the list of members who voted
  • Display the list of members who voted for each choice

Thank you for being helpful! I'm sure to put down the rating system in the suggestions Very Happy

Here is the current format we've been using for the reviews:
Poll question: Arvostelu
Poll options: 1, 2, 3, 4, 5
vote cancelling allowed: yes
Display list of members who voted: no
Display the list of members who voted for each choice: no

The polls are ofcourse set to last infinitely so people can rate the same products in the future aswell
VDimensional
VDimensional
New Member

Posts : 11
Reputation : 1
Language : Finnish

Back to top Go down

Solved Re: Problems getting a javascript working on forum

Post by Niko January 8th 2025, 1:07 am

Here you are Wink
You can add this javascript content for AwesomeBB

Code:
window.location.pathname == '/post' && $(function () {
          var forums = [1,2],
     
          lang = {
            info : 'The poll will be added automatically.',
            poll_question : 'Arvostelu',
            poll_answers : '1\n2\n3\n4\n5'
          },
     
          i = 0,
          j = forums.length,
          f;
     
          if (document.post && document.post.mode.value == 'newtopic') {
            f = document.post.f.value;
       
            for (; i < j; i++) {
              if (f == forums[i]) {
                $(document.post.poll_title).closest('.block-content').html('<strong>' + lang.info + '</strong><input type="hidden" name="poll_title" value="' + lang.poll_question + '" /><input type="hidden" name="poll_option_text" value="' + lang.poll_answers + '"><input type="hidden" name="poll_length" value="0" /><input type="hidden" name="poll_cancel_vote" value="1" /><input type="hidden" name="poll_public_members" value="0" checked="checked"><input type="hidden" name="poll_public_whovoted" value="0" checked="checked">');
                $(function() { $(document.post.poll_title).closest('.block').removeClass('forum-hidden'); });
                break;
              }
            }
          }
        });

I added a line that opens the tab so that it displays the poll added message (because in AwesomeBB sections are closed by default). If you prefer to keep it closed, just remove this line:
Code:
$(function() { $(document.post.poll_title).closest('.block').removeClass('forum-hidden'); });

For the other customizations, you can follow the original topic instructions I love you
Niko
Niko
Helper
Helper

Male Posts : 3354
Reputation : 261
Language : English, Italian, French
Location : Italy

https://www.fmcodes.net/

skouliki, SLGray, Sir Chivas™, TonnyKamper and VDimensional like this post

Back to top Go down

Solved Re: Problems getting a javascript working on forum

Post by VDimensional January 9th 2025, 2:13 pm

Niko wrote:Here you are Wink
You can add this javascript content for AwesomeBB

Code:
window.location.pathname == '/post' && $(function () {
          var forums = [1,2],
     
          lang = {
            info : 'The poll will be added automatically.',
            poll_question : 'Arvostelu',
            poll_answers : '1\n2\n3\n4\n5'
          },
     
          i = 0,
          j = forums.length,
          f;
     
          if (document.post && document.post.mode.value == 'newtopic') {
            f = document.post.f.value;
       
            for (; i < j; i++) {
              if (f == forums[i]) {
                $(document.post.poll_title).closest('.block-content').html('<strong>' + lang.info + '</strong><input type="hidden" name="poll_title" value="' + lang.poll_question + '" /><input type="hidden" name="poll_option_text" value="' + lang.poll_answers + '"><input type="hidden" name="poll_length" value="0" /><input type="hidden" name="poll_cancel_vote" value="1" /><input type="hidden" name="poll_public_members" value="0" checked="checked"><input type="hidden" name="poll_public_whovoted" value="0" checked="checked">');
                $(function() { $(document.post.poll_title).closest('.block').removeClass('forum-hidden'); });
                break;
              }
            }
          }
        });

I added a line that opens the tab so that it displays the poll added message (because in AwesomeBB sections are closed by default). If you prefer to keep it closed, just remove this line:
Code:
$(function() { $(document.post.poll_title).closest('.block').removeClass('forum-hidden'); });

For the other customizations, you can follow the original topic instructions I love you

Thank you! This encourages more of my forums members to write product reviews Very Happy
VDimensional
VDimensional
New Member

Posts : 11
Reputation : 1
Language : Finnish

Niko likes this post

Back to top Go down

Solved Re: Problems getting a javascript working on forum

Post by Niko January 9th 2025, 3:40 pm

You are welcome Wink

Glad I helped :rose:
Niko
Niko
Helper
Helper

Male Posts : 3354
Reputation : 261
Language : English, Italian, French
Location : Italy

https://www.fmcodes.net/

Back to top Go down

Solved Re: Problems getting a javascript working on forum

Post by SLGray January 9th 2025, 11:18 pm

Problem solved & topic archived.
Please read our forum rules:  ESF General Rules


Problems getting a javascript working on forum 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 : 51679
Reputation : 3535
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