Reply To: How to maintain a counter/score based on values in radio boxes?
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?
July 3, 2018 at 3:43 PM
#10420
Keymaster
Oh, I should have made it clear. It's the JavaScript code, so you should put it in your theme main script file. Or better, create a JS file (assume its name is custom.js
) in your theme folder, and put this content inside:
$( function() {
// Snippet goes here.
var total = 0;
$( '.like input:checked' ).each( function() {
total += $(this).val();
} );
// Output total somewhere
$( '#selector' ).text( total );
// More snippet goes here.
} );
And then in your functions.php file of the theme, add the following code:
add_action( 'wp_enqueue_scripts', function() {
wp_enqueue_script( 'custom-handle', get_template_directory_uri() . '/custom.js', array( 'jquery' ), '', true );
} );
This thing is quite technical, though.