- Experience Community
- Developer Corner
- Custom Code
- Create a questions with random text
Create a questions with random text
- March 28, 2019
- 18 replies
- 861 views
18 replies
- Level 3 ●●●
- 197 replies
- March 28, 2019
- Level 8 ●●●●●●●●
- 6084 replies
- March 28, 2019
- 7 replies
- March 28, 2019
- Level 3 ●●●
- 197 replies
- March 29, 2019
- 7 replies
- April 15, 2019
- Level 3 ●●●
- 197 replies
- April 23, 2019
- 7 replies
- May 22, 2019
- Level 3 ●●●
- 197 replies
- May 23, 2019
- 7 replies
- May 27, 2019
and our code is we have two embedded fields as:
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
});
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
/*var order = "${e://Field/random1}"
Qualtrics.SurveyEngine.setEmbeddedData('random1', order);
document.getElementById("random1").innerHTML = order;*/
var words = ["cat", "dog", "horse"]; //Your words
var i = Math.floor(Math.random() * words.length); //randomly select an index
var my_word = words[i]; //select a word
Qualtrics.SurveyEngine.setEmbeddedData( 'words', my_word); //Send the word to the Qualtrics output, otherwise you would not know which participant get which word
//Qualtrics.SurveyEngine.getEmbeddedData('words')
document.getElementById("random1").innerHTML = my_word; //show the word to respondents
var words1 = ["red", "blue", "green"]; //Your words
var i = Math.floor(Math.random() * words1.length); //randomly select an index
var my_word1 = words1[i]; //select a word
Qualtrics.SurveyEngine.setEmbeddedData( 'words1', my_word1); //Send the word to the Qualtrics output, otherwise you would not know which participant get which word
document.getElementById("random2").innerHTML = my_word1; //show the word to respondents
});
Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/
});
and the HTML looks like
what percentage of <div id="random1">.</div> do you think are <div id="random2">.</div>
If we use piped text of embedded data field, it is not getting displayed to the respondents. Adding loop and merge produces 6400 columns. Can you help me storing this embedded data fields?- Level 3 ●●●
- 197 replies
- May 28, 2019
- 7 replies
- May 29, 2019
This is our embedded fields in survey flow
!
It is choosing the Last word from the list while saving back to the QUALTRICS. Is there a possible way to store the randomly displayed word to Qualtrics?- Level 3 ●●●
- 197 replies
- May 30, 2019
- 7 replies
- June 19, 2019
- 2 replies
- November 20, 2019
- Level 8 ●●●●●●●●
- 6084 replies
- November 20, 2019
- 2 replies
- November 20, 2019
- Level 1 ●
- 2 replies
- June 18, 2024
Hi! I had a couple questions on this:
>
>
>1. Make your 10,000 words choices in a MC question.
>2. Use advanced randomization to randomly display one word and evenly present
>3. Add a page break after the question
>3. Use JS to either hide the question or click the next button
>4. Pipe the displayed choices from your hidden question into your question text
>
>If it were me, I would put the 10,000 words in an external database and write a web service script to randomly grab one a return it as an embedded variable. Then I would pipe the embedded variable into the question text.
Can you link to a post that describes how to hide the question in JS like this? I have not been able to find it. Alternatively, I have not found a post which explains how to pipe from an external database (Excel in my case)
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
Scanning file for viruses.
Sorry, we're still checking this file's contents to make sure it's safe to download. Please try again in a few minutes.
OKThis file cannot be downloaded
Sorry, our virus scanner detected that this file isn't safe to download.
OK