Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

How shall I extract date variable form database to be screening condition for the following questions?

Q1_Unix
Q1_Year
Q1_Month
Q1_Day
Q1_ReadableString
I hope to take Q1_Day data,the conditions of screening

Begin Unverified Perl
if (GETValue("Q1_day") == 15)
{ADD(ctList,1);
}
if (GETVALUE("Q1_day") == 16)
{ADD(ctList,2);
}
End Unverified


<input type="text" id="datePicker" placeholder="dd/mm/yyyy">
<input name="Q1_Unix" id="Q1_Unix" type="hidden" value="">
<input name="Q1_Year" id="Q1_Year" type="hidden" value="">
<input name="Q1_Month" id="Q1_Month" type="hidden" value="">
<input name="Q1_Day" id="Q1_Day" type="hidden" value="">
<input name="Q1_ReadableString" id="Q1_ReadableString" type="hidden" value="">

<script>
$('#datePicker').datepicker({
    onClose: function(){
        var date = $('#datePicker').datepicker('getDate');
         
        // Unix
        $('#Q1_Unix').val(date.getTime());
         
        // Y, M, D
        $('#Q1_Year').val(date.getFullYear());
        $('#Q1_Month').val(date.getMonth() + 1); // months are zero-based
        $('#Q1_Day').val(date.getDate());
         
        // Readable string
        $('#Q1_ReadableString').val($.datepicker.formatDate('MM d, yy', date));
    }
});
</script>
related to an answer for: Date picker in free format question
asked Jan 17 by anonymous

1 Answer

0 votes
When using unverified Perl, Sawtooth Script functions must be written in all caps.  Additionally, names of questions and lists must be surrounded by quotation marks.

Begin Unverified Perl
if (GETVALUE("Q1_day") == 15)
{ADD("ctList",1);
}
if (GETVALUE("Q1_day") == 16)
{ADD("ctList",2);
}
End Unverified
answered Jan 17 by Zachary Platinum Sawtooth Software, Inc. (86,525 points)
How do I get the date from the system data, I do not get this data Q1_day,how to get?
Thank you!
You also need to use "Q1_Day" instead of "Q1_day" - the name needs to be exactly the name of the variable you use in your free format question.
Get it,Thanks!
...