Question asking time of the day | XM Community
Skip to main content
Question

Question asking time of the day


Forum|alt.badge.img+1

Hi,

 

does anyone know a way to show a question asking participants to indicate the time of the day in which they performed a certain behavior?


I am looking for a response format in which they can put hours and minutes (possibly using the 24h format), without having a field text which will provide very dirty data.

 

I tried some of the javascript for a time picker I found in the community but I could not make them work.

 

Thank you!

Giulia

10 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5918 replies
  • March 11, 2025

Use a text entry question and use JS to change the input type attribute from ‘text’ to ‘time’:

Qualtrics.SurveyEngine.addOnload(function() {
  this.getQuestionContainer().querySelectorAll("[input=text]")[0].setAttribute("type","text");
});

 


Forum|alt.badge.img+1
  • Author
  • Level 1 ●
  • 7 replies
  • March 11, 2025

Thanks TomG.

 

I tried what you said, but I still don’t get any changes. 

 

I set a text entry question as you said and added the JavaScript as in the pic, but still getting a normal text box in the preview.

What I am doing wrong?

Thanks!

Best


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5918 replies
  • March 11, 2025
Giulia_P wrote:

Thanks TomG.

 

I tried what you said, but I still don’t get any changes. 

 

I set a text entry question as you said and added the JavaScript as in the pic, but still getting a normal text box in the preview.

What I am doing wrong?

Thanks!

Best

The selector should be [input=text] instead of [input=time]


Forum|alt.badge.img+1
  • Author
  • Level 1 ●
  • 7 replies
  • March 11, 2025

Like this?

Nothing changed. Still getting the same text box as in the previous pic.


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5918 replies
  • March 11, 2025

Sorry, I had the selector wrong. It should be:

Qualtrics.SurveyEngine.addOnload(function() {
	this.getQuestionContainer().querySelectorAll("input[type=text]")[0].setAttribute("type","time");
});

 


Forum|alt.badge.img+1
  • Author
  • Level 1 ●
  • 7 replies
  • March 11, 2025

Still not working.

 

I am using the preview mode. Could it be that I have to publish the survey to see it work?


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 5918 replies
  • March 11, 2025

It works for me in preview mode:

 


Forum|alt.badge.img+1
  • Author
  • Level 1 ●
  • 7 replies
  • March 11, 2025

Then I don’t know what else to do.

 

Thanks anyway

Best

Giulia


Forum|alt.badge.img+1
  • Author
  • Level 1 ●
  • 7 replies
  • March 11, 2025

Actually, it works using a Form Field instead of a Text Entry.

 

Is there a way to make it in 24h format instead of PM/AM?

 

Thanks!


Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • 2028 replies
  • March 12, 2025

@Giulia_P that’s set by the browser based on the user’s preferences. You can’t control that. At your end, the value will always be in HH:mm format.

 


Leave a Reply