Check out the LimeSurvey source code on GitHub!

Passing Date to Text Field

5 years 8 months ago #61970 by COMPGURL
How can I copy a date value from one question to a short free text question on the same page?

Please Log in to join the conversation.

5 years 8 months ago #61981 by tpartner
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">
			// 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());

Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in to join the conversation.

5 years 8 months ago #62129 by TMSWhite

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.


Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form