Willkommen, Gast
Benutzername: Passwort: Angemeldet bleiben:

THEMA: Date field Questions

Date field Questions 4 Monate 4 Stunden her #106656

  • simogeo
  • simogeos Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 18
  • Karma: 0
Hi all,


I'm starting a survey with Limesurvey Version 2.05+ Build 140320 (thanks to the developers for this nice project).

Using date field, I'm facing 2 issues :
  • The first one concerns the maximal date : I've seen into the doc manual.limesurvey.org/Question_type_-_Date that I can set an expression as maximal date. I would like to set the current year. I so tried date("Y") but rendering the question does not work. Can someone point what I'm doing wrong?
  • Second issue : I'd like to have only year displayed. I d'ont want month neither day. How can I do that? (I know one workaround would be to change the question type to numeric and adding a validation regex to validate the date but I want to know if it is possible with date)

Thanks a lot for your reply.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Date field Questions 4 Monate 2 Stunden her #106663

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4058
  • Dank erhalten: 742
  • Karma: 341
If only asking for the year, why not just use a List (dropdown) question?

manual.limesurvey.org/Question_type_-_List_%28Dropdown%29



.
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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Date field Questions 4 Monate 19 Minuten her #106671

  • simogeo
  • simogeos Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 18
  • Karma: 0
The dropdown would be to long ... something like from 1900 to current year. SO I guess it is not an option.

Thanks anyway.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Date field Questions 4 Monate 10 Minuten her #106673

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4058
  • Dank erhalten: 742
  • Karma: 341
Well, wouldn't the dropdown it the date question be the same length?
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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Date field Questions 3 Monate 4 Wochen her #106676

  • simogeo
  • simogeos Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 18
  • Karma: 0
I'm not sure what do you mean.

The values would all be 4 chars length but there would be more than 100 entries. I don't really want to type them manually ....
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Date field Questions 3 Monate 4 Wochen her #106677

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4058
  • Dank erhalten: 742
  • Karma: 341
Quick Add:
Capture_2014-03-25.png


2014;2014
2013;2013
2012;2012
2011;2011
2010;2010
2009;2009
2008;2008
2007;2007
2006;2006
2005;2005
2004;2004
2003;2003
2002;2002
2001;2001
2000;2000
1999;1999
1998;1998
1997;1997
1996;1996
1995;1995
1994;1994
1993;1993
1992;1992
1991;1991
1990;1990
1989;1989
1988;1988
1987;1987
1986;1986
1985;1985
1984;1984
1983;1983
1982;1982
1981;1981
1980;1980
1979;1979
1978;1978
1977;1977
1976;1976
1975;1975
1974;1974
1973;1973
1972;1972
1971;1971
1970;1970
1969;1969
1968;1968
1967;1967
1966;1966
1965;1965
1964;1964
1963;1963
1962;1962
1961;1961
1960;1960
1959;1959
1958;1958
1957;1957
1956;1956
1955;1955
1954;1954
1953;1953
1952;1952
1951;1951
1950;1950
1949;1949
1948;1948
1947;1947
1946;1946
1945;1945
1944;1944
1943;1943
1942;1942
1941;1941
1940;1940
1939;1939
1938;1938
1937;1937
1936;1936
1935;1935
1934;1934
1933;1933
1932;1932
1931;1931
1930;1930
1929;1929
1928;1928
1927;1927
1926;1926
1925;1925
1924;1924
1923;1923
1922;1922
1921;1921
1920;1920
1919;1919
1918;1918
1917;1917
1916;1916
1915;1915
1914;1914
1913;1913
1912;1912
1911;1911
1910;1910
1909;1909
1908;1908
1907;1907
1906;1906
1905;1905
1904;1904
1903;1903
1902;1902
1901;1901
1900;1900
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.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: simogeo

Date field Questions 3 Monate 4 Wochen her #106681

  • simogeo
  • simogeos Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 18
  • Karma: 0
Many thanks Tony.

Indeed, it is working well and the result is quite beautiful but it does not satisfy my first demand (of having the current year dynamically - see : www.limesurvey.org/en/forum/design-issue...eld-questions#106656)

Still, for now, I think I will use that. Thanks again.
Der Administrator hat öffentliche Schreibrechte deaktiviert.

Date field Questions 3 Monate 4 Wochen her #106684

  • tpartner
  • tpartners Avatar
  • OFFLINE
  • LimeSurvey Team
  • Beiträge: 4058
  • Dank erhalten: 742
  • Karma: 341
...but it does not satisfy my first demand (of having the current year dynamically...
  1. Add the future years to your dropdown question
  2. Set up your survey to use JavaScript.
  3. Add this script to the question source.
<script type="text/javascript" charset="utf-8">	
 
	$(document).ready(function() {
 
		var thisYear = new Date().getFullYear();
 
		$('#question{QID} .dropdown-item option').filter(function() {
			return $(this).attr('value') > thisYear;
		}).remove();
	});
</script>

Here's a working example:

Dateianhang:

Dateiname: limesurvey_question_17897.lsq
Dateigröße: 37 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.
Letzte Änderung: 3 Monate 4 Wochen her von tpartner.
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Folgende Benutzer bedankten sich: simogeo

Date field Questions 3 Monate 4 Wochen her #106688

  • simogeo
  • simogeos Avatar
  • OFFLINE
  • Fresh Lemon
  • Beiträge: 18
  • Karma: 0
This bricolage will do the trick!

Thanks for pointing me to manual.limesurvey.org/Workarounds page which is worth value
Letzte Änderung: 3 Monate 4 Wochen her von simogeo. Begründung: typo
Der Administrator hat öffentliche Schreibrechte deaktiviert.
Moderatoren: ITEd
Ladezeit der Seite: 0.206 Sekunden
Donation Image