Taking data from a specific dropdown in a side by side | XM Community
Solved

Taking data from a specific dropdown in a side by side

  • 28 December 2020
  • 2 replies
  • 46 views

Hey all,
I'm working on a question that asks the start time and the end time for an incident in a side by side. There are 3 columns, and 2 rows. The columns are Hour, Minute, and AM/PM, and the rows are Start Time and End Time, respectively.
Screen Shot 2020-12-28 at 9.46.17 AM.png
I have the following code that is supposed to be pulling the start time answers onPageSubmit:
let sHH = jQuery(".SBS1 option:selected").text();
let sMM = jQuery(".SBS2 option:selected").text();
let sAP = jQuery(".SBS3 option:selected").text();
alert("Start Hour: " + sHH);
alert("Start Minute: " + sMM);
alert("Start Second: " + sAP);

However, when I submit the page, sHH will return the start hour and the end hour both. For example, if I selected the start hour as being 01 and the end hour as 02, sHH will equal "0102" instead of just "01".
Ideally, I'd like both of these answers separately on the same page, so I can calculate the duration between the times on page submit. Piped text will not work for this.
Any suggestions? Thanks in advance!

icon

Best answer by TomG 28 December 2020, 17:09

View original

2 replies

Userlevel 7
Badge +27

let sHH = jQuery(".SBS1 select").first().find("option:selected").text();

https://www.qualtrics.com/community/discussion/comment/32938#Comment_32938Thanks! That worked. For the documentation of this incase anyone comes into a similar problem, https://www.w3schools.com/jquery/jquery_ref_traversing.asp helped a lot for the understanding of it.
Thanks again! Have a great day!

Leave a Reply