Welcome, Guest
Username: Password: Remember me

TOPIC: Passing Date to Text Field

Passing Date to Text Field 3 years 1 month ago #61970

  • COMPGURL
  • COMPGURL's Avatar
  • OFFLINE
  • Fresh Lemon
  • Posts: 14
  • Karma: 0
How can I copy a date value from one question to a short free text question on the same page?
The administrator has disabled public write access.

Re: Passing Date to Text Field 3 years 1 month ago #61981

  • tpartner
  • tpartner's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 4054
  • Thank you received: 741
  • Karma: 341
1) Set up your survey to use JavaScript.

2) Add the following script to the source of one of the questions. Replace "DD" and "TT" with the respective question IDs.

The script puts a listener on the date input. When a change is detected, the value is inserted into the text question input.
<script type="text/javascript" charset="utf-8">
 
	$(document).ready(function(){
 
			// The question IDs
			var qDate = DD;
			var qText = TT;
 
			// A listener on the date input
			$('#question'+qDate+' input[type="text"]').change(function() {
 
				// Load the text input
				$('#question'+qText+' input.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.
The administrator has disabled public write access.

Re: Passing Date to Text Field 3 years 1 month ago #62129

  • TMSWhite
  • TMSWhite's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 759
  • Thank you received: 82
  • Karma: 36
Tony-

I'm hoping that Issue #5104 will support such requests without the need for JavaScript. I can extend the equation parser to allow assignment of registered variables; and all of the server-side processing is working. (Some more details at this thread)

Seems one strategy might be to have the proposed Equation question type generate JavaScript functions that would all be called (or conditionally called) with each on_change event. The parser does know which variables are used in each equation, so conceivably we could limit the function calls to only on_change events attached to those variables, but that may be more trouble than it's worth.

/Tom
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.167 seconds
Donation Image