New to Javascript--help with coding multiple choice questions | XM Community
Skip to main content
Hey!



I'm a researcher w/ the University of Michigan; we're using Qualtrics to help classify a database of 15k public policies. I'm wondering if anyone could give us some advice about how we could use Javascript to include a multiple-choice survey question that would both 1) allow creators to randomly insert a hyperlinked url to the summary page of one of these 15k policies, and 2) allow respondents to click on the link, enabling them to reference the summary page for the duration of their time completing the survey.



Feel free to ask any follow-up questions if need be. Looking forward to hearing some insights.



Best,



Nate
Hi, @Nate,



If I'm understanding, you want to randomly present one of 15K URLs persistently throughout a survey?



I would:



1. On the intro page of your survey, define this JavaScript:



var urls = ["a", "b", "c", ... "15000th"];

Qualtrics.SurveyEngine.setEmbeddedData("url", urls["${rand://int/0:14999}"])



Where you delimit the 15K URLs instead of a/b/c/etc. It will use the Qualtrics random number generator to pick one from the urls array and assign that to the Embedded Data field "url"



2. Put ${e://Field/url} wherever you want it to appear in the survey (perhaps the header if you want it to be persistent).

Leave a Reply