Text: Calendar Widget
This article will help you program a Calendar Exercise
Calendar Exercise
This article will show you how to program a Calendar Exercise using a standard text question
Instructions - Calendar Exercise
- Add a 'Text Fields' question type to your survey with all of the appropriate responses
- See article: Add a Question: Text Fields
- Add 2 responses. These will hold the date in the corresponding formats in each response
- yy-mm-dd
- mm/dd/yy
- Access the Overall Question Settings
- See articles: Overall Question Settings
- In these settings change the min and max range to both be 10 characters
- Add the code below to your 'ADD JAVASCRIPT'.
- See article: Adding JavaScript and/or CSS to a Question
var picker = jQuery(".cm-qtext"); var showBox = picker.find("input[type='text']"); var realBox = jQuery(".cm-text-response-set li:nth-child(1) .cm-text-input"); var realBox2 = jQuery(".cm-text-response-set li:nth-child(2) .cm-text-input"); picker.datepicker({ dateFormat : "mm/dd/yy", maxDate : 0, onSelect: function(dateText) { showBox.val(dateText); realBox2.val(dateText); }, altField : realBox, altFormat : "yy-mm-dd" }); jQuery(".fieldset").hide(); showBox.attr("readonly", true); realBox.val("");
- See article: Adding JavaScript and/or CSS to a Question
- Add the code below to your 'ADD CSS'.
- See article: Adding JavaScript and/or CSS to a Question
/****** DISPLAY DATE ONCE SELECTED ******/ .cm-qtext input[type='text'] { border: none; background: inherit; width: auto; font-size: 90%; font-weight: bold; color: red; } /****** CALENDAR INTERFACE *******/ .ui-datepicker { margin-top: 1%; } .ui-datepicker-calendar th { border-bottom: 1px solid black; }
- See article: Adding JavaScript and/or CSS to a Question
- If you would like the date to be displayed, add the following into the Source Code Editor
- See article: Source Code Editor
<input type="text">
- See article: Source Code Editor
- If you want more information and/or uses for this exercise, visit: http://api.jqueryui.com/datepicker/