Hi all,
I am new to programming and could very much use your help.
For my study, I want participants to click on a hyperlink that opens a website in the same window. Upon clicking, I want the survey to automatically continue to the next question.
(Because ON the website, I embedded the Qualtrics survey. I want them to see the next question here, not again the question that mentions "click HERE to go to the website". Which would be very confusing).
I have made the following code (based on suggestions I found online), which oddly enough seems to work sometimes, but not always. Could anyone help me out? I would greatly appreciate suggestions on how to improve the code so it always works.
JAVASCRIPT CODE:
Qualtrics.SurveyEngine.addOnload(function() {
$('extLink').on('click', function(name, event) {
Qualtrics.SurveyEngine.setEmbeddedData('clicked', '1');
jQuery("#NextButton").click();
});
Additionally, I have used the following settings:
- In the survey flow, I added an embedded data field named 'clicked' which is set to 0.
- The hyperlink ID is set as 'ExtLink'
When I look at my data, the first part of the code seems to always work. Hence, clicked is always set to 1 upon clicking on the URL. However, the second part is only triggered sometimes, most of the times it isn't. It seems as if the new URL is opened PRIOR to going to the next question. Hence, this part of the code is not run.
Thanks in advance!