Quantcast
Channel: Topics in Category: Can I do this with LimeSurvey? - LimeSurvey forums
Viewing all articles
Browse latest Browse all 17529

Entering Numbers & a dropdown for currency - by: tpartner

$
0
0
Well, it looks okay to me except you forgot to hide the text inputs in column 2 (see script below).

Do you have any JS errors?

<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function(){
 
		// Identify this question
		var thisQuestion = $('#question{QID}');
 
		// Assign column-specific classes
		$('table.subquestion-list tr', thisQuestion).each(function(i) {
 
			$('> *:gt(0)', this).each(function(i){
				$(this).addClass('column-'+(i+1));
				$(this).attr('data-column', i+1);
			});
		});
 
		// Hide the text inputs
		$('.answer-item.column-2 input[type="text"]').hide();
 
		// Define the select element (dropdown)
		var select1 = '<select class="inserted-select"> \
							<option value="">-- Please Choose --</option> \
							<option value="EUR">EUR</option> \
							<option value="USD">USD</option> \
							</select>';
 
		// Insert the select elements into column 2
		$('.answer-item.column-2').append(select1);
 
		// Initial dropdown values in column  (if the question has already been answered)
		$('.answer-item.column-2 input[type="text"]').each(function(i){
			if($.trim($(this).val()) != '') {
				$(this).closest('td').find('.inserted-select').val($.trim($(this).val()));
			}
		});
 
		// Listener on the dropdowns (insert selected values into hidden text input)
		$('.inserted-select').change(function() {
			$(this).closest('td').find('input[type="text"]').val($(this).val());
		});
	});
</script>

Sample survey attached:

File Attachment:

File Name: limesurvey_survey_859762.lss
File Size: 18 KB

Viewing all articles
Browse latest Browse all 17529

Trending Articles