Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

THEMA: Modify Image Attribute based on List Selection

Modify Image Attribute based on List Selection 8 Monate 1 Woche her #102839

  • dweisser
  • dweissers Avatar
  • OFFLINE
  • Bronze Donor
  • Beiträge: 203
  • Dank erhalten: 5
  • Karma: 5
Hi TPartner -

I'm using the image tick workaround. I don't think it should interfere with the code you so graciously supplied. But, alas, I copied and pasted it directly, and it doesn't seem to work.

I activated a Test Survey here if it is possible for you to see?

Also, the image is attached to a question - not in the template...what do you think?

Thank you so much.
David
Letzte Änderung: 8 Monate 1 Woche her von dweisser.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Modify Image Attribute based on List Selection 8 Monate 1 Woche her #102845

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4139
  • Dank erhalten: 767
  • Karma: 348
That link just leads to your survey listing page.
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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Modify Image Attribute based on List Selection 8 Monate 1 Woche her #102848

  • dweisser
  • dweissers Avatar
  • OFFLINE
  • Bronze Donor
  • Beiträge: 203
  • Dank erhalten: 5
  • Karma: 5
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Modify Image Attribute based on List Selection 8 Monate 1 Woche her #102852

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4139
  • Dank erhalten: 767
  • Karma: 348
Oops, my mistake - change both instances of ".question1342" to "#question1342"
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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Modify Image Attribute based on List Selection 8 Monate 1 Woche her #102853

  • dweisser
  • dweissers Avatar
  • OFFLINE
  • Bronze Donor
  • Beiträge: 203
  • Dank erhalten: 5
  • Karma: 5
Completely works. You absolutely rock!
Happy holidays from Nebraska TPartner.
David
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Modify Image Attribute based on List Selection 6 Monate 3 Wochen her #104882

  • dweisser
  • dweissers Avatar
  • OFFLINE
  • Bronze Donor
  • Beiträge: 203
  • Dank erhalten: 5
  • Karma: 5
Hey T,
Any chance you have insight into how to modify the image attribute using a multi-select question?

If my question is 1628 and my subquestions are sq001, sq002 and sq003, I'm not sure how to adjust to accommodate this structure...as well as the fact that instead of radio buttons and dropdowns, they are check boxes.

If you could point me int eh right direction, I'd sure appreciate it.
Thanks as always,
David
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Modify Image Attribute based on List Selection 6 Monate 3 Wochen her #104903

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4139
  • Dank erhalten: 767
  • Karma: 348
I'm not sure how that would work if multiple checked boxes are possible.
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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Modify Image Attribute based on List Selection 6 Monate 3 Wochen her #104914

  • dweisser
  • dweissers Avatar
  • OFFLINE
  • Bronze Donor
  • Beiträge: 203
  • Dank erhalten: 5
  • Karma: 5
I would like to show an image for each check box....
So, up to three images could show if there are three subquestions. I think the logic is the same, but instead of #question1488, should it be something like #question1488SQ001. Instead of input.radio:checked').attr('value') == 'Y', should it input.checkbox:checked').attr('value') == 'True'?

$(document).ready(function(){
 
	// Initial setting
	if($('#question1488 input.radio:checked').attr('value') == 'Y') {
		$('#variableimage1615').attr('src', 'http://www.domain.com/surveyassets/images/y1488_1.png');
	}
	if($('#question1488 input.radio:checked').attr('value') == 'N') {
		$('#variableimage1615').attr('src', 'http://www.domain.com/surveyassets/images/blank1x1.png');
	}	
 
	// Listener on the radios
	$('#question1488 input.radio').click(function(event){
		var clickedvalue = $(this).attr('value');
		if(clickedvalue == 'Y') {
			$('#variableimage1488').attr('src', 'http://www.domain.com/surveyassets/images/y1488_1.png');
		}
		if(clickedvalue == 'N') {
			$('#variableimage1488').attr('src', 'http://www.domain.com/surveyassets/images//blank1x1.png');
		}		
	});
});
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Modify Image Attribute based on List Selection 6 Monate 2 Wochen her #104981

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4139
  • Dank erhalten: 767
  • Karma: 348
You will need to look for the "checked" property on the check-boxes.

There will certainly be more elegant ways to do it but this script should be fairly easy to follow.

Assumptions...
- Survey ID - 111111
- Group ID - 222
- Question ID - 333
- Subqestion codes - SQ001, SQ002, SQ003
- Image IDs - variableimage1, variableimage2, variableimage3

<script type="text/javascript" charset="utf-8">	
 
	$(document).ready(function(){
 
		// Define the image sources
		var img1Original = $('#variableimage1').attr('src');
		var img2Original = $('#variableimage2').attr('src');
		var img3Original = $('#variableimage3').attr('src');		
		var img1New = 'http://www.domain.com/surveyassets/images/image_1_new.png';
		var img2New = 'http://www.domain.com/surveyassets/images/image_2_new.png';
		var img3New = 'http://www.domain.com/surveyassets/images/image_3_new.png';
 
		// Initial settings
		if($('#answer111111X222X333SQ001').is(':checked')) {
			$('#variableimage1').attr('src', img1New);
		}
		if($('#answer111111X222X333SQ002').is(':checked')) {
			$('#variableimage2').attr('src', img2New);
		}
		if($('#answer111111X222X333SQ003').is(':checked')) {
			$('#variableimage3').attr('src', img3New);
		}
 
		// Listeners on the 3 checkboxes
		$('#answer111111X222X333SQ001').change(function(event) {
			if($(this).is(':checked')) {
				$('#variableimage1').attr('src', img1New);
			}
			else {
				$('#variableimage1').attr('src', img1Original);
			}
		});
		$('#answer111111X222X333SQ002').change(function(event) {
			if($(this).is(':checked')) {
				$('#variableimage2').attr('src', img2New);
			}
			else {
				$('#variableimage2').attr('src', img2Original);
			}
		});
		$('#answer111111X222X333SQ003').change(function(event) {
			if($(this).is(':checked')) {
				$('#variableimage3').attr('src', img3New);
			}
			else {
				$('#variableimage3').attr('src', img3Original);
			}
		});
	});
</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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Modify Image Attribute based on List Selection 6 Monate 2 Wochen her #105055

  • dweisser
  • dweissers Avatar
  • OFFLINE
  • Bronze Donor
  • Beiträge: 203
  • Dank erhalten: 5
  • Karma: 5
Once again, my sincerest thanks. Works beautifully.
David
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Moderatoren: ITEd
Ladezeit der Seite: 1.478 Sekunden
Donation Image