Have an idea?

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

Set up question as time of day with AM/PM selection

I need to setup a question where the respondent enters the time of day in a numeric box and then is able to select AM/PM in a drop down next to it.  Is this possible?

What time did you see that movie?   ___________  AM / PM
asked May 22 by anonymous

2 Answers

0 votes
The free format question can be used to create custom questions.  I created a free format, added a numeric variable named "Time" and a dropdown variable named "AmPm," and then set the HTML to this:

What time did you see that movie?

<input name="[% QuestionName() %]_Time" id="[% QuestionName() %]_Time" class="numeric_input" type="tel" size="5">

<select name="[% QuestionName() %]_AmPm" id="[% QuestionName() %]_AmPm">
    <option selected value=""> AM / PM </option>
    <option value="1"> AM </option>
    <option value="2"> PM </option>

Does this serve your needs?
answered May 22 by Zachary Platinum Sawtooth Software, Inc. (114,725 points)
0 votes
Maybe the easiest way to do this is with a bit of simple HTML in a Free Format question. Create a free format question. (In this example, we'll call it "Q1".) Then add a text type variable (say, "_Time").  Put script like this into the HTML section of the question:

What time did you see that movie?
<input type="time" name="Q1_Time"></input>

When you preview it within the question, it may show just a blank text box. But when you view it in most browsers, it will show a picker for hours, minutes, and AM/PM.
answered May 22 by Aaron Hill Gold Sawtooth Software, Inc. (10,095 points)
Thanks for chipping in, Aaron.  "type=time" is a cool input tool, but it does come with limited browser support, as you mentioned.  Here's the caniuse.com page on it:


Users that make use of "type=time" will want to double check that their survey is working acceptably across all the browsers that they need to support.