Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Can I use Javascript to trigger save/submit page

  • maxrandolph
  • maxrandolph's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 6 months ago #141739 by maxrandolph
This is a follow-up to my previous question regarding submit buttons on every question page.

I've been attempting to save the answers on a page by clicking an html element within a question. I have tried using:

document.limesurvey.move.value = 'movenext';
document.limesurvey.submit();

as the onclick event, but does not seem to save the answers unfortunately. Is there a javascript method I can call to save the current answers?

Thanks.

Here is my current code:
Code:
<h1 onclick="myFunction()">submit</h1>
<script type="text/javascript" charset="utf-8">
    function myFunction() {
      if($('#movesubmitbtn').length > 0) {
        document.limesurvey.move.value = 'movesubmit';
      }
      else {
        document.limesurvey.move.value = 'movenext';
      }
      document.limesurvey.submit();
        };
 
</script>
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 6 months ago - 7 years 6 months ago #141743 by tpartner
Try something like this to click the "Next" button.

Code:
$('#movesubmitbtn, #movenextbtn').trigger('click');

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 7 years 6 months ago by tpartner.
The following user(s) said Thank You: maxrandolph
The topic has been locked.
  • maxrandolph
  • maxrandolph's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
7 years 6 months ago #141770 by maxrandolph
Replied by maxrandolph on topic Can I use Javascript to trigger save/submit page
Exactly what I needed. Thank you again so much. :)
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose