Welcome to the LimeSurvey Community Forum

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

POST form on end message doesn't get executed?

  • Magnar
  • Magnar's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 10 months ago #200656 by Magnar
Good day LimeSurvey community,

I am trying to use a POST form in the end message of a survey, so a participant can subscribe to our homepage newsletter if he so desires. I'm using the following form for that:

Code:
<form accept-charset="utf-8" action="https://www.beispiel.de/newsletter/" id="allNewsletterForm" method="post" name="allNewsletterForm" target="_blank">
  <input type="submit" value="Newsletter abonnieren" />
  <input name="salutationID" type="hidden" value="{if(TOKEN:ATTRIBUTE_3.code=='Herr', '1', '2')}" />
  <input name="userFirstname" type="hidden" value="{TOKEN:FIRSTNAME}" />
  <input name="userLastname" type="hidden" value="{TOKEN:LASTNAME}" />
  <input name="userEmail" type="hidden" value="{TOKEN:EMAIL}" />
</form>

During testing, as soon as I arrive at the end message and click the submit button to order the newsletter, I'm getting redirected to the welcome page of the survey and the form's action doesn't get executed (no newsletter order is being sent).

After importing the survey .lsa to one of our older LS installations (2.73), the POST form appears to be working fine (newsletter order shows up in a separate window for a second, then the end message can be seen again).

So far I've encountered this issue on our own hosted version (3.21.1) and a LimeSurvey Professional version (3.22).

Do you have an idea what could be causing this behavior?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 10 months ago #200688 by tpartner
Replied by tpartner on topic POST form on end message doesn't get executed?
I think the problem is that you are inserting a form into a form (the #limesurvey form already exists on the page).

Try using JavaScript to insert your form after the #limesurvey form.

Code:
<script type="text/javascript" charset="utf-8">  
  $(document).on('ready pjax:scriptcomplete',function(){
 
    $('#limesurvey').after('<form accept-charset="utf-8" action="https://www.beispiel.de/newsletter/" id="allNewsletterForm" method="post" name="allNewsletterForm" target="_blank">\
      <input type="submit" value="Newsletter abonnieren" />\
      <input name="salutationID" type="hidden" value="{if(TOKEN:ATTRIBUTE_3.code=='Herr', '1', '2')}" />\
      <input name="userFirstname" type="hidden" value="{TOKEN:FIRSTNAME}" />\
      <input name="userLastname" type="hidden" value="{TOKEN:LASTNAME}" />\
      <input name="userEmail" type="hidden" value="{TOKEN:EMAIL}" />\
    </form>');
    });
</script>

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The following user(s) said Thank You: Magnar
The topic has been locked.
  • Magnar
  • Magnar's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
3 years 10 months ago #200693 by Magnar
Well, that worked. Thank you very much for the quick response, tpartner!

It seems odd to me though. Why does the Limesurvey form continue onto the end message? It's not like the content is relevant to the participant's answers anymore, right? Or is it there because of the end page URL option in the survey settings?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
3 years 10 months ago #200697 by tpartner
Replied by tpartner on topic POST form on end message doesn't get executed?
I believe it is required for print-answers, etc.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose