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.
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!
Page 1 / 1
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
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.