Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

THEMA: Language Switch as List (radio)

Language Switch as List (radio) 11 Monate 2 Tage her #96332

  • TwentyTwo
  • TwentyTwos Avatar
Hi,

I would like to use the Language Switch question but not as drop down but just as a radio list.

Therefore I create a new radio list question with (in this case) 3 answers for the specific languages that I have in my Survey.

In the code itself I try to manipulate this with JS:
<script type="text/javascript" charset="utf-8" >
$(document).ready(function() {
 
if ($( '#answer68224X108X852A1' ).attr('checked') == true ){
 document.getElementById('lang').value="nl-informal"; 
};
if ($( '#answer68224X108X852A2' ).attr('checked') == true ){
 document.getElementById('lang').value="de"; 
};
if ($( '#answer68224X108X852A3' ).attr('checked') == true ){
 document.getElementById('lang').value="nl"; 
};
 
 
};
</script>

This is not working as I would expect, any idea how to change this?
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Language Switch as List (radio) 11 Monate 1 Tag her #96344

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 3844
  • Dank erhalten: 690
  • Karma: 330
Try something like:
<script type="text/javascript" charset="utf-8" >
	$(document).ready(function() {
 
		$( '#answer68224X108X852A1' ).click(function() {
			document.getElementById('lang').value="nl-informal"; 
		});
		$( '#answer68224X108X852A2' ).click(function() {
			document.getElementById('lang').value="de"; 
		});
		$( '#answer68224X108X852A3' ).click(function() {
			document.getElementById('lang').value="nl"; 
		});
	};
</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.

Language Switch as List (radio) 11 Monate 1 Tag her #96347

  • TwentyTwo
  • TwentyTwos Avatar
Thanks Tony,

See your point, however not working - I think I still have something wrong on the getElement - it should be something like setting something right?
Not sure if you can see it quickly?

I will play around a bit more later as well and post the solution when founded.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Language Switch as List (radio) 11 Monate 1 Tag her #96349

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 3844
  • Dank erhalten: 690
  • Karma: 330
Ah, it seems that the <input id="lang"> element is only present in the language-switch question so you will need to add it to your question source.

Also, I had a small syntax error in my script.

So, add this to the source of the question in all languages:
<input id="lang" type="hidden" value="" name="lang">
<script type="text/javascript" charset="utf-8" >
	$(document).ready(function() {
 
		$( '#answer68224X108X852A1' ).click(function() {
			document.getElementById('lang').value="nl-informal"; 
		});
		$( '#answer68224X108X852A2' ).click(function() {
			document.getElementById('lang').value="de"; 
		});
		$( '#answer68224X108X852A3' ).click(function() {
			document.getElementById('lang').value="nl"; 
		});
	});
</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.
Moderatoren: ITEd
Ladezeit der Seite: 0.187 Sekunden
Donation Image