- Posts: 4
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Datepicker in Multiple Short Text question
- ggcsoarbc
- Topic Author
- Offline
- New Member
Less
More
8 years 1 month ago #132790
by ggcsoarbc
Datepicker in Multiple Short Text question was created by ggcsoarbc
I'm sure this is possible, but I need direction from someone more experience than myself. I found and applied the solution to get a datepicker to pop up in one column of an array style question, but now I want to add a datepicker to just one row of a multiple short text question and I can't figure out how to make it work! Can someone help me?
Thanks!
Thanks!
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10108
- Thank you received: 3593
8 years 1 month ago #132795
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Datepicker in Multiple Short Text question
LimeSurvey version?
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- ggcsoarbc
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
8 years 1 month ago #132796
by ggcsoarbc
Replied by ggcsoarbc on topic Datepicker in Multiple Short Text question
Version 2.06+ Build 151215
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10108
- Thank you received: 3593
8 years 1 month ago #132797
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Datepicker in Multiple Short Text question
This should work. Adjust the "timeRow " variable as necessary. (this example inserts the timepicker in row 2)
Sample survey attached:
Code:
<script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify some elements var thisQuestion = $('#question{QID}'); var surveyRoot = location.pathname.split('index.php')[0]; // Row to insert the timepicker var timeRow = 2; // Define the timepicker function insertPicker() { $('li.question-item:eq('+(timeRow-1)+') input[type="text"]', thisQuestion).datetimepicker( { minInterval: (1000*60*60), // 1hr dateFormat: 'dd M yy', timeFormat: 'HH:mm', start: { }, // start picker options end: { } // end picker options }); } // Insert the timepicker if (!$.isFunction($.fn.timepicker)) { $('head link[rel="stylesheet"]').last().after('<link rel="stylesheet" href="'+surveyRoot+'third_party/jquery-ui-timepicker-addon/jquery-ui-timepicker-addon.css" type="text/css" media="screen">'); $.getScript( surveyRoot+'third_party/jquery-ui-timepicker-addon/jquery-ui-timepicker-addon.js', function( data, textStatus, jqxhr ) { insertPicker(); }); } else { insertPicker(); } }); </script>
Sample survey attached:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The following user(s) said Thank You: Stan, ggcsoarbc
The topic has been locked.
- ggcsoarbc
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
8 years 1 month ago #132798
by ggcsoarbc
Replied by ggcsoarbc on topic Datepicker in Multiple Short Text question
First - thank you for your prompt response.
When I import your sample survey, that works, but when I copy and paste into my question, at first it didn't work. I played around with it and learned that if I have a "Display rows" under advanced settings set to 1 (which is what I had, so that the other boxes can be made larger, if necessary), then the picker does not work. When I removed the 1 and left that setting blank, then the picker works.
I don't actually want a time in this field - just a date - how do I make it for a date only? (format yy/mm/dd).
And, is it possible to allow one of the rows to have more than one row showing, without messing up the datepicker ability?
When I import your sample survey, that works, but when I copy and paste into my question, at first it didn't work. I played around with it and learned that if I have a "Display rows" under advanced settings set to 1 (which is what I had, so that the other boxes can be made larger, if necessary), then the picker does not work. When I removed the 1 and left that setting blank, then the picker works.
I don't actually want a time in this field - just a date - how do I make it for a date only? (format yy/mm/dd).
And, is it possible to allow one of the rows to have more than one row showing, without messing up the datepicker ability?
The topic has been locked.
- ggcsoarbc
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
8 years 1 month ago - 8 years 1 month ago #132799
by ggcsoarbc
Replied by ggcsoarbc on topic Datepicker in Multiple Short Text question
I've got it to work without the time.
Thank you for your help. But now that I can't put in the number of rows showing without breaking the date picker, how can I make it so that one of the rows (in particular, it is the 3rd row) shows more rows available for text input?
Thanks again.
Thank you for your help. But now that I can't put in the number of rows showing without breaking the date picker, how can I make it so that one of the rows (in particular, it is the 3rd row) shows more rows available for text input?
Thanks again.
Last edit: 8 years 1 month ago by ggcsoarbc.
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10108
- Thank you received: 3593
8 years 1 month ago #132800
by tpartner
As far as I know, the datepicker only works on text input elements.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Datepicker in Multiple Short Text question
You cannot do that - the rows are either all text inputs (single-row) or textareas (multi-row);how can I make it so that one of the rows (in particular, it is the 3rd row) shows more rows available for text input?
As far as I know, the datepicker only works on text input elements.
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13637
- Thank you received: 2491
8 years 1 month ago - 8 years 1 month ago #132813
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Datepicker in Multiple Short Text question
Hi,
Not directly linked with the question, just some js survey hacker :
I like to use
But can break with included template
But now, you can use
PS: then index.php system can be broken with some specific parameters url
Not directly linked with the question, just some js survey hacker :
Code:
var surveyRoot = location.pathname.split('index.php')[0];
I like to use
Code:
var surveyRoot = "{TEMPLATEURL}../../../
But now, you can use
Code:
var surveyRoot = "{SURVEYRESOURCESURL}../../../
PS: then index.php system can be broken with some specific parameters url
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Last edit: 8 years 1 month ago by DenisChenu. Reason: remove a /
The topic has been locked.
- Stan
- Offline
- Junior Member
Less
More
- Posts: 28
- Thank you received: 0
8 years 1 month ago #133372
by Stan
Replied by Stan on topic Datepicker in Multiple Short Text question
Thanks Tpartner for this.
A question, how can i successfully adjust the code, so that it would be possible to:
- Display only the month and the year ('MM yy')?
- set the minDate and the maxDate?
A question, how can i successfully adjust the code, so that it would be possible to:
- Display only the month and the year ('MM yy')?
- set the minDate and the maxDate?
The topic has been locked.
- tpartner
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 10108
- Thank you received: 3593
8 years 1 month ago #133404
by tpartner
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Replied by tpartner on topic Datepicker in Multiple Short Text question
You can do that with the
normal jQuery UI Datepicker
, using the dateFormat, minDate and maxDate options. Something like this:
Sample survey attached:
Code:
Q1: <script type="text/javascript" charset="utf-8"> $(document).ready(function() { // Identify some elements var thisQuestion = $('#question{QID}'); // Row to insert the timepicker var timeRow = 2; // Insert the timepicker $('li.question-item:eq('+(timeRow-1)+') input[type="text"]', thisQuestion).datepicker({ dateFormat: 'mm-yy', minDate: new Date("February 01, 2016"), maxDate :new Date("May 31, 2016") }); }); </script>
Sample survey attached:
Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Attachments:
The following user(s) said Thank You: Stan
The topic has been locked.
- Stan
- Offline
- Junior Member
Less
More
- Posts: 28
- Thank you received: 0
8 years 1 month ago #133467
by Stan
Replied by Stan on topic Datepicker in Multiple Short Text question
Thanks a lot Tpartner,
i actually tried to play with the jQuery UI but it wasn't so easy
i actually tried to play with the jQuery UI but it wasn't so easy
The topic has been locked.