Welcome to the LimeSurvey Community Forum

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

Dynamic end message results only after refresh - why?

  • steffenschaffhausen
  • steffenschaffhausen's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 4 weeks ago #181866 by steffenschaffhausen
Dynamic end message results only after refresh - why? was created by steffenschaffhausen
Hi,

I do try some things with chart.js to automate reports after filling the survey.

I put some source code in html and java script in the end message.

It works, but only after I refresh one time the page.



If I put the same source code in the welcome message it works without refreshing (unfortunately I would not have the result of the variables before the people fill the survey ;-) ).
Code:
<p align="left"><b><span style="font-size: 32px; margin: 21px 0;">JS RADAR UND BEDINGTE TEXTAUSGABE</span></b></p>
<div style="width:70%;"><canvas height="400" id="myChart3" width="400"></canvas></div>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.4.0/Chart.min.js"></script><script type="text/javascript">
 
//VARIABLES
var auswahl = 1;
var array_titel = ["TITEL0","titel1"];
 
var array_inhalt = ["INHALT0: Das ist Text mit dem Index 0","INHALT1: Dieser Text hat Index 1"];
 
var array_profil = [[1,2,3,4,5],[5,4,3,2,1]];
var array_bezeichnungen = [["elegant","stilvoll","charmant","boheme","klassisch"],["eklig","ranzig","stinkend","unangenehm","gammlig"]];
 
var titel = array_titel[auswahl];
var inhalt = array_inhalt[auswahl];
 
 
// RADAR
var ctx = document.getElementById("myChart3");
var myChart = new Chart(ctx, {
    scaleStartValue: 0,
    type: 'radar',
    data: {
        labels: array_bezeichnungen[auswahl],
        datasets: [{
            label: 'RADAR',
            data: array_profil[auswahl],
          borderColor: ['rgba(020,150,020,1)']
        }]
    },
    options: {
 
        scales: {
            ticks: {
                beginAtZero: true,
            }
        }
    }
});
</script>
 
<p align="left"><b><span style="font-size: 28px; margin: 21px 0;">Das ist <script type="text/javascript">document.write(titel);</script> mit <script type="text/javascript">document.write(inhalt);</script></span></b></p>
 


I added a link to show you what happens in the following three cases:
1.) Code in welcome message ==> works
2.) Code in equation ==> does work after refresh
3.) Code in end message ==> does work after refresh

www.uebernimm-zukunft.org/lime/index.php...778?lang=de-informal


I do not want to expect from the participants to refresh the page so they get the results.

So what do I do wrong (sorry to all experts - I am not a programmer - I just copy and paste code)?



Thanks a lot in advance!!!

Steffen
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 4 weeks ago #181890 by tpartner
Try disabling AJAX in the survey theme options.

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: DenisChenu
The topic has been locked.
  • steffenschaffhausen
  • steffenschaffhausen's Avatar Topic Author
  • Offline
  • New Member
  • New Member
More
5 years 4 weeks ago #181891 by steffenschaffhausen
Replied by steffenschaffhausen on topic Dynamic end message results only after refresh - why?
Thanks a lot. Works so far. What problems do I create by disabling AJAX?
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
5 years 4 weeks ago - 5 years 4 weeks ago #181893 by tpartner
None at all. It was intended to speed up page load but is somewhat prone to causing errors.

If using the latest version, please file a bug report and give a link here so we can follow it.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 5 years 4 weeks ago by tpartner.
The following user(s) said Thank You: DenisChenu
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose