Support MB Frontend Submission How to maintain a counter/score based on values in radio boxes? Reply To: How to maintain a counter/score based on values in radio boxes?

#10423
Anh TranAnh Tran
Keymaster

For my understanding, what this js is doing is counting the number of checked items with class=like, and displaying the counter, right?

Yes, that's right.

I was wondering, can I also include this in the page from where I launch the Frontend Submission? Because then I can control the location where I want the counter to be displayed.

Yes, by putting it in a custom JS file will help you control everything easier.

By the way, I created the .js file, stored it in the js folder of my theme, and included the call in the functions.php, but it doesn’t show a counter, and I don’t know if it counts…

As it's in the js folder of your theme, you need to change the code in functions.php code to this:

add_action( 'wp_enqueue_scripts', function() {
    wp_enqueue_script( 'custom-handle', get_template_directory_uri() . '/js/custom.js', array( 'jquery' ), '', true );
} );

And please change the #selector in the snippet to the CSS selector of the element you want to show the total likes.