==================
(Write here your question/remark)
Please help us help you and fill where relevant:
LimeSurvey version:
LimeSurvey Community Edition
Versione 6.6.2+240827
Own server or LimeSurvey Cloud: Own server
Survey theme/template:
==================
Hello,
I need to create a question that randomly selects an image from a folder I created on the LimeSurvey server (containing 32 images). To do this, I created a "Text Display" type question and inserted a JavaScript code. Unfortunately, in the question preview, a blank question appears as if it can't read the code. At this point, I tried with a very basic test code, and I realized that my LimeSurvey can't execute JavaScript.
Here is my code:
<p><img id="randomImage" src="" alt="Immagine casuale" /></p>
<script type="text/javascript">
var numberOfImages = 32;
var randomIndex = Math.floor(Math.random() * numberOfImages) + 1;
var imageFolderPath = 'https:folder_path';
var imageFileName = 'Scenario_' + randomIndex + '.jpg'; //the images are named Scenario_1, Scenario_2, … , Scenario_32
document.getElementById('randomImage').src = imageFolderPath + imageFileName;
</script>
In your opinion, is the problem in the code? Is there some setting related to JavaScript execution? If so, can you recommend a new method to achieve what I need?
I also tried this second method, but it doesn't seem to work either:
I created an "Equation" type question where I generate a random number from 1 to 32.
Then I created a "Text Display" type question where I inserted the following code:
<p><img alt="Random Image" src="Folder_path/Scenario_{G03Q03}.jpg" /></p>
Where G03Q03 is the Code of the question where I've generated the random number. I already checked the accessibility of the images, the correcteness of the folder path and the images are all saves as jpg.
Thanks in advance for your help.