Bienvenue, Invité
Nom d'utilisateur : Mot de passe : Se souvenir de moi
  • Page :
  • 1

SUJET : get value from star rating and display text

get value from star rating and display text il y a 4 mois 1 semaine #92437

  • adishardis
  • Portrait de adishardis
  • Hors ligne
  • Silver Donor
  • Messages : 57
  • Karma: 0
Hi, I have no clue on how to achieve this and below is my futile attempt thus far...
<script type="text/javascript" charset="utf-8">
$(document).ready(function(){
 
 var sVala = $('#question263 input:radio[name=java725987X26X263]:checked').val()
 
		 if(sVala = 1) {
				document.getElementById('stjerna').innerHTML = 'Uselt';
			}
 
 
                  if(sVala = 2) {
				document.getElementById('stjerna').innerHTML = 'inte jättebra';
                  }
 	 	  if(sVala = 3) {
				document.getElementById('stjerna').innerHTML = 'Varken eller';
                  }
 		  if(sVala = 4) {
				document.getElementById('stjerna').innerHTML = 'Ganska bra';
                  }
  		  if(sVala = 5) {
				document.getElementById('stjerna').innerHTML = 'Föredömligt';
                  }
});
</script>

Please help a friend in need :)
/Adam
L'administrateur à désactivé l'accès en écriture pour le public.

Re: get value from star rating and display text il y a 4 mois 1 semaine #92453

  • tpartner
  • Portrait de tpartner
  • Hors ligne
  • LimeSurvey Team
  • Messages : 2948
  • Remerciements reçus 448
  • Karma: 254
Adam, where do you want to display the text? Can you provide a mockup?
Cheers,
Tony

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
L'administrateur à désactivé l'accès en écriture pour le public.

Re: get value from star rating and display text il y a 4 mois 1 semaine #92455

  • adishardis
  • Portrait de adishardis
  • Hors ligne
  • Silver Donor
  • Messages : 57
  • Karma: 0
starratingTEXT.png


So I gather that I would insert a div (id=stjerna) in the question area and css it to show in the right place. Though it would be ok to have the text to the left as well!

Thanks for taking time to look into this!!

/Adam
L'administrateur à désactivé l'accès en écriture pour le public.

Re: get value from star rating and display text il y a 4 mois 1 semaine #92536

  • tpartner
  • Portrait de tpartner
  • Hors ligne
  • LimeSurvey Team
  • Messages : 2948
  • Remerciements reçus 448
  • Karma: 254
Try this:
<script type="text/javascript" charset="utf-8">
	$(document).ready(function(){
 
		// Identify the question
		var q1 = $('#question{QID}');
 
		// A listener on the stars
		$('.star-rating', q1).click(function () {
 
			// The clicked value
			var value = $(this).text();
 
			// Define the text
			var insertedtext = '';
			switch(value) {
				case '1':
					insertedtext = 'Uselt';
					break;
				case '2':
					insertedtext = 'inte jättebra';
					break;
				case '3':
					insertedtext = 'Varken eller';
					break;
				case '4':
					insertedtext = 'Ganska bra';
					break;
				case '5':
					insertedtext = 'Föredömligt';
					break;
			}
 
			// Pipe the text to the div
			$('#stjerna').text(insertedtext);		
		});
	});
</script>
Cheers,
Tony

LimeSurvey is open-source and run entirely by volunteers so please consider donating to support the project.
L'administrateur à désactivé l'accès en écriture pour le public.
Cet utilisateur a été remercié pour son message par: adishardis

Re: get value from star rating and display text il y a 4 mois 1 semaine #92539

  • adishardis
  • Portrait de adishardis
  • Hors ligne
  • Silver Donor
  • Messages : 57
  • Karma: 0
:woohoo:

You are a Genius!

And congratulations on reaching your fundraiser goal!!
L'administrateur à désactivé l'accès en écriture pour le public.
  • Page :
  • 1
Modérateurs: DenisChenu, ITEd
Temps de génération de la page : 0.247 secondes
Donation Image