Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Array num with radio in last column

Array num with radio in last column 6 months 2 weeks ago #103172

  • MikeConom
  • MikeConom's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 39
  • Thank you received: 1
  • Karma: 0
When i choose the r1 (radio button) then the next question to be visible
The administrator has disabled public write access.

Array num with radio in last column 6 months 2 weeks ago #103204

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4050
  • Thank you received: 740
  • Karma: 341
Okay, the way that I would handle that would be to supplement the listener on the radios to load their value into the hidden text inputs when clicked (I suspect you want that anyway). Then you can fire the fixnum_checkconditions() function as discussed previously.
<script type="text/javascript" charset="utf-8">$(document).ready(function() {
 
		// Identify this question
		var qID = {QID};
		var thisQuestion = $('#question'+qID);
 
		// Define the select element (radio)
		var select1 = '<div id="insertedRadio"> \
		<input type="radio" title="ans_1" value="1" name="Radio1" /> \
		</div>';
		var select2 = '<div id="insertedRadio"> \
		<input type="radio" title="ans_2" value="2" name="Radio1" /> \
		</div>';
 
		// Hide the text inputs
		$('#question'+qID+' .answer_cell_005 input[type="text"]').addClass('hidden').hide();
		$('#question'+qID+' .answer_cell_006 input[type="text"]').addClass('hidden').hide();
 
		// Insert the select elements
		$('#question'+qID+' .answer_cell_005').append(select1);
		$('#question'+qID+' .answer_cell_006').append(select2);
 
		// Listener on the radios
		$('tr.subquestions-list input[type="radio"]', thisQuestion).click(function(event) {
			var thisRow = $(this).closest('tr.subquestions-list');
			var thisCell = $(this).closest('td.question-item');
			var thisTextInput = $('input[type="text"]', thisCell);
			$('input[type="text"]', thisRow).val('');
			$('input[type="text"]', thisCell).val($(this).attr('value'));
			// Check conditions...
			checkThisRowConditions(thisRow)
		});
 
		// Keyup listener on the text inputs
		$('tr.subquestions-list input[type="text"]', thisQuestion).keyup(function(event) {
			if($(this).val() != ''){
				var thisRow = $(this).closest('tr.subquestions-list');
				$('input[type="radio"]', thisRow).attr('checked', false);
				$('input[type="text"].hidden', thisRow).val('');
				// Check conditions...
				checkThisRowConditions(thisRow)
			}
		});
 
		// Paste listener on the text inputs
		$('tr.subquestions-list input[type="text"]', thisQuestion).bind('paste', function () {
			var thisInput = $(this);		
			setTimeout(function() {	 // Little timeout so the val() is available
				if($(thisInput).val() != ''){
					var thisRow = $(thisInput).closest('tr.subquestions-list');
					$('input[type="radio"]', thisRow).attr('checked', false);
					$('input[type="text"].hidden', thisRow).val('');
					// Check conditions...
					checkThisRowConditions(thisRow)
				}
			}, 100);
		});
 
		function checkThisRowConditions(thisRow) {
			$('input[type="text"]', thisRow).each(function(i) {
				fixnum_checkconditions($(this).attr('value'), $(this).attr('name'), $(this).attr('type'));
			});
		}
	});
</script>

File Attachment:

File Name: limesurvey_survey_685454.lss
File Size: 20 KB
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.
The following user(s) said Thank You: MikeConom

Array num with radio in last column 6 months 2 weeks ago #103236

  • MikeConom
  • MikeConom's Avatar
  • OFFLINE
  • Junior Lime
  • Posts: 39
  • Thank you received: 1
  • Karma: 0
Ok Tony

this is the solution and its working fine

Also i have added a new line in section Listener on the radios
$('input[type="text"]', thisTextInput).val($(this).attr('value'));
so keep in results the value of radio

Thanks
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.134 seconds
Donation Image