Welcome, Guest
Username: Password: Remember me

TOPIC: Random pictures only shown once

Random pictures only shown once 8 months 2 weeks ago #98701

  • Andrea
  • Andrea's Avatar
  • OFFLINE
  • Gold Donor
  • Posts: 33
  • Karma: 0
Hi,

I use below script from limesurvey workaroungs to Display Pictures in random order:

Is there a possibility to remove the shown picture and to present in the next group the remaining 3 pcitures?





<script>

$(document).ready(

function(){

// Find a random number (here between 1 and 4)

var randNumber = Math.floor(Math.random()*4 + 1);

// Save the number as answer of this question

$('input#answerSSSSSXGGXQQ').val(randNumber);

// Hide this answer field

document.getElementById("answerSSSSSXGGXQQ").style.display='none';

// Show the picture

picString = '<img src="pic/' + String(randNumber) + '.jpg">';

document.getElementById('pic').innerHTML = picString;

}

);</script>

Thanks in advance.

Andrea
The administrator has disabled public write access.

Random pictures only shown once 8 months 2 weeks ago #98719

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 3813
  • Thank you received: 683
  • Karma: 328
Try something like this:

<script type="text/javascript" charset="utf-8">	
	$(document).ready(function(){
 
		// Retrieve the random number
		var randNumber =  '{INSERTANS:SSSSSXGGXQQ}';
 
		// Load the images
		$('#pic').html('<img src="pic1.jpg"><img src="pic2.jpg"><img src="pic3.jpg"><img src="pic4.jpg">');
 
		//Remove the previously shown image
		$('#pic img[src="pic'+randNumber+'"]').remove();
	});
</script>
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
Last Edit: 8 months 2 weeks ago by tpartner.
The administrator has disabled public write access.

Random pictures only shown once 8 months 2 weeks ago #98730

  • Andrea
  • Andrea's Avatar
  • OFFLINE
  • Gold Donor
  • Posts: 33
  • Karma: 0
I put the code in a short text question, however, it still shows the Picture twice.

Any idea?
The administrator has disabled public write access.

Random pictures only shown once 8 months 2 weeks ago #98736

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 3813
  • Thank you received: 683
  • Karma: 328
Can you activate a test survey?
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Random pictures only shown once 8 months 2 weeks ago #98737

  • Andrea
  • Andrea's Avatar
  • OFFLINE
  • Gold Donor
  • Posts: 33
  • Karma: 0
Here it is

www.6ws.at/umfrage/index.php/527471/lang-de


Thanks
Andrea

Attachment limesurvey_survey_527471.lss not found

The administrator has disabled public write access.

Random pictures only shown once 8 months 2 weeks ago #98738

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 3813
  • Thank you received: 683
  • Karma: 328
Okay, now I'm confused about what you are trying to do.

All I see is 3 questions, all of which are set to display a random image. I don't see one question to display a random image followed by another question to display "the remaining 3 pcitures".

I also don't see my code anywhere.
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.

Random pictures only shown once 8 months 2 weeks ago #98828

  • Andrea
  • Andrea's Avatar
  • OFFLINE
  • Gold Donor
  • Posts: 33
  • Karma: 0
Hi tpartner,

I put your code in a short text question and set it to hide (question 2 and 4).

No I cancled the hidden question and put your code into question 2 and 3.

Still doesn't work.
The administrator has disabled public write access.

Random pictures only shown once 8 months 1 week ago #98873

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 3813
  • Thank you received: 683
  • Karma: 328
Now, in questions 2 and 3, I see that you have BOTH the code to display "the remaining 3 pictures" AND the code to display a random image. You need to use one code snippet or the other.

Additionally, the images don't seem to be available (broken paths).
Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.122 seconds
Donation Image