Dynamic end message results only after refresh - why?

More
1 month 1 day ago #181866 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 ;-) ).
<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

https://www.uebernimm-zukunft.org/lime/index.php/558778?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

Please Log in or Create an account to join the conversation.

LimeSurvey Partners
More
1 month 1 day 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

Please Log in or Create an account to join the conversation.

More
1 month 1 day ago #181891 by steffenschaffhausen
Thanks a lot. Works so far. What problems do I create by disabling AJAX?

Please Log in or Create an account to join the conversation.

More
1 month 1 day ago - 1 month 1 day 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: 1 month 1 day ago by tpartner.
The following user(s) said Thank You: DenisChenu

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!