Welcome, Guest
Username: Password: Remember me

TOPIC: Language Switch as List (radio)

Language Switch as List (radio) 11 months 21 hours ago #96332

  • TwentyTwo
  • TwentyTwo's 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?
The administrator has disabled public write access.

Language Switch as List (radio) 11 months 16 hours ago #96344

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 3837
  • Thank you received: 688
  • 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.
The administrator has disabled public write access.

Language Switch as List (radio) 11 months 14 hours ago #96347

  • TwentyTwo
  • TwentyTwo's 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.
The administrator has disabled public write access.

Language Switch as List (radio) 11 months 13 hours ago #96349

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 3837
  • Thank you received: 688
  • 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.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.175 seconds
Donation Image