Welcome, Guest
Username: Password: Remember me

TOPIC: Array question with answers in dropdown boxes

Re: Array question with answers in dropdown boxes 5 months 2 weeks ago #109868

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4369
  • Thank you received: 828
  • Karma: 381
What has changed on your installation.

Do you get any JavaScript errors?


.
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.

Re: Array question with answers in dropdown boxes 5 months 2 weeks ago #109910

  • ricardo
  • ricardo's Avatar
  • OFFLINE
  • Expert Lime
  • Posts: 117
  • Thank you received: 1
  • Karma: 0
the only thing that has changed is that I updated my installation...I'm now using 2.05+ (140520)
The administrator has disabled public write access.

Re: Array question with answers in dropdown boxes 5 months 2 weeks ago #109911

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4369
  • Thank you received: 828
  • Karma: 381
2.05 uses a different version of jQuery which may be causing some errors. Can you activate a test survey for us to see>
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.

Re: Array question with answers in dropdown boxes 1 month 3 days ago #113816

  • ricardo
  • ricardo's Avatar
  • OFFLINE
  • Expert Lime
  • Posts: 117
  • Thank you received: 1
  • Karma: 0
Hi guys,

I'm coming back to this issiue. I want to create a with answers in dropdown boxes...I'm using the Tony's code. The problem is that the column doesn't show up...just an empty space. This is a link to an example...

ayura.udea.edu.co/limesurvey/index.php/561473/lang-es

this is the code I'm using

Disponibilidad y estado actual de la infraestructura del nivel preescolar
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {

var qID = {QID};

// Define the select element (dropdown)
var select1 = '<select class="insertedSelect"> \
<option value="">-- Please Choose --</option> \
<option value="Nuevo">Nuevo</option> \
<option value="Reparado">Reparado</option> \
<option value="Deteriorado">Deteriorado</option> \
<option value="Inservible">Inservible</option> \
</select>';

// Hide the text inputs
$('#question'+qID+' .answer_cell_004 input[type="text"]').hide().parent().hide();

// Insert the select elements
$('#question'+qID+' .answer_cell_004').append(select1);

// Initially select an option if the question has already been answered
$('#question'+qID+' .answer_cell_004 input[type="text"]').each(function(i){
if($(this).val()) {
$(this).closest('td').find('.insertedSelect').val($(this).val());
}
});

// Listener on the dropdowns - insert selected values into hidden text input
$('.insertedSelect').change(function() {
$(this).closest('td').find('input[type="text"]').val($(this).val());
});
});
</script>
The administrator has disabled public write access.

Re: Array question with answers in dropdown boxes 1 month 2 days ago #113827

  • tpartner
  • tpartner's Avatar
  • NOW ONLINE
  • LimeSurvey Team
  • Posts: 4369
  • Thank you received: 828
  • Karma: 381
Ah, in pre-2.05 versions the text inputs were placed inside the labels, which was poorly formed HTML. Now they are siblings of the labels.

Change this line:
$('#question'+qID+' .answer_cell_004 input[type="text"]').hide().parent().hide();

To this:
$('#question'+qID+' .answer_cell_004 input[type="text"]').hide();

So, the complete code:
<script type="text/javascript" charset="utf-8">
	$(document).ready(function() {
 
		var qID = {QID};
 
		// Define the select element (dropdown)
		var select1 = '<select class="insertedSelect">\
					<option value="">-- Please Choose --</option>\
					<option value="Nuevo">Nuevo</option>\
					<option value="Reparado">Reparado</option>\
					<option value="Deteriorado">Deteriorado</option>\
					<option value="Inservible">Inservible</option>\
				</select>';
 
		// Hide the text inputs
		$('#question'+qID+' .answer_cell_004 input[type="text"]').hide();
 
		// Insert the select elements
		$('#question'+qID+' .answer_cell_004').append(select1);
 
		// Initially select an option if the question has already been answered
		$('#question'+qID+' .answer_cell_004 input[type="text"]').each(function(i){
			if($(this).val()) {
				$(this).closest('td').find('.insertedSelect').val($(this).val());
			}
		});
 
		// Listener on the dropdowns - insert selected values into hidden text input
		$('.insertedSelect').change(function() {
			$(this).closest('td').find('input[type="text"]').val($(this).val());
		});
	});
</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: 1 month 2 days ago by tpartner.
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.119 seconds
Donation Image