Title: Is there a Javascript on QSM submit function?
Last modified: May 9, 2022

---

# Is there a Javascript on QSM submit function?

 *  Resolved [daemonhanky](https://wordpress.org/support/users/daemonhanky/)
 * (@daemonhanky)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/is-there-a-javascript-on-qsm-submit-function/)
 * I’m looking to run a javascript function when the submit is successful for any
   quiz.
 * Is there a javascript event/function that I can listen for in order to do this?
 * Something like on(‘qsm_submit_success’, function(){ do_something });
 * Thank you for an amazing plugin!

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Thread Starter [daemonhanky](https://wordpress.org/support/users/daemonhanky/)
 * (@daemonhanky)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/is-there-a-javascript-on-qsm-submit-function/#post-15628972)
 * Here is the code I’ve attempted to use.
 * //store score after the user submits
    $quizID = ”; $(‘.quiz’).on(‘click’, ‘.qsm-
   submit-btn’, function(){ $quizID = $(this).parents(‘form’).attr(‘id’); console.
   log($quizID); }); document.addEventListener( ‘qmnFormSubmit’, $(‘#’+$quizID),
   function( event ) { console.log(‘hello2’); moduleName = $(this).parents(‘.quiz’).
   attr(‘id’).toString(); score = $(‘.score’).text().toString(); }, false);
 *  [sumitsanadhya](https://wordpress.org/support/users/sumitsanadhya/)
 * (@sumitsanadhya)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/is-there-a-javascript-on-qsm-submit-function/#post-15630742)
 * Hi [@daemonhanky](https://wordpress.org/support/users/daemonhanky/)
 * I need to discuss this with my development team. Hopefully, I will get back to
   you with the solution.
 * Regards,
    Sumit
 *  Thread Starter [daemonhanky](https://wordpress.org/support/users/daemonhanky/)
 * (@daemonhanky)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/is-there-a-javascript-on-qsm-submit-function/#post-15631384)
 * I appreciate the help.
 * Thanks Sumit.
 *  Thread Starter [daemonhanky](https://wordpress.org/support/users/daemonhanky/)
 * (@daemonhanky)
 * [4 years, 1 month ago](https://wordpress.org/support/topic/is-there-a-javascript-on-qsm-submit-function/#post-15631641)
 * I’ve come up with an interim solution if anyone is interested.
 * The loading animation starts when the quiz is busy processing results, so I am
   checking for if that exists when submit is clicked, then after a time I do what
   I want
    (in this case creating a cookie with the score).
 * jQuery code is below:
 *     ```
       //store score after the user submits
         $('.quiz').on('click', '.qsm-submit-btn', function(){
           quizID = $(this).parents('.quiz').attr('id').toString();
   
           if($('.qsm_quiz_processing_box').length > -1){
             setTimeout(function(){
               moduleName = quizID;
               score = $('.score').text().toString();
               if(localStorage.getItem(moduleName) === null){
                 localStorage.setItem(moduleName, score);
               }
             },3000);
           }
         });
       ```
   
 * Thanks.
    -  This reply was modified 4 years, 1 month ago by [daemonhanky](https://wordpress.org/support/users/daemonhanky/).
      Reason: fixed typo
 *  [sumitsanadhya](https://wordpress.org/support/users/sumitsanadhya/)
 * (@sumitsanadhya)
 * [4 years ago](https://wordpress.org/support/topic/is-there-a-javascript-on-qsm-submit-function/#post-15635552)
 * Hi [@daemonhanky](https://wordpress.org/support/users/daemonhanky/) ,
 * There is a hook **qsm_after_quiz_submit** which you can use for calling custom
   js functions after submitting any quiz. Please check the below-given example.
   Let me know if you need more help.
 * jQuery(document).on(‘qsm_after_quiz_submit’,function(event,quiz_form_id){
    event.
   preventDefault(); let polarQuestions = jQuery(‘.question-type-polar-s’); if(polarQuestions.
   length >0){ qsmPolarSlider(‘answer’, polarQuestions); } });
 * Regards,
    Sumit
 *  Thread Starter [daemonhanky](https://wordpress.org/support/users/daemonhanky/)
 * (@daemonhanky)
 * [4 years ago](https://wordpress.org/support/topic/is-there-a-javascript-on-qsm-submit-function/#post-15635786)
 * Exactly what I needed.
 * Thank you so much!

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Is there a Javascript on QSM submit function?’ is closed to new replies.

 * ![](https://ps.w.org/quiz-master-next/assets/icon-128x128.png?rev=3158087)
 * [Quiz and Survey Master (QSM) - Easy Quiz and Survey Maker](https://wordpress.org/plugins/quiz-master-next/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/quiz-master-next/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/quiz-master-next/)
 * [Active Topics](https://wordpress.org/support/plugin/quiz-master-next/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/quiz-master-next/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/quiz-master-next/reviews/)

## Tags

 * [javascript](https://wordpress.org/support/topic-tag/javascript/)

 * 6 replies
 * 2 participants
 * Last reply from: [daemonhanky](https://wordpress.org/support/users/daemonhanky/)
 * Last activity: [4 years ago](https://wordpress.org/support/topic/is-there-a-javascript-on-qsm-submit-function/#post-15635786)
 * Status: resolved