Show html table attributes in csv file | XM Community
Skip to main content
Dear all,

In my questionnaire, I have a table (that is written in html and programmed with javascript). This table consists of two programs (two columns) which feature randomly appearing attributes. The respondent has then to choose which program she likes better. For the analysis, it is important to know which attributes each respondent saw. Therefore it would be great if this would be shown in the csv file. Otherwise I would have to do it by hand I guess and that would take forever. Does anyone have an idea how I can program that this attributes are also shown in the csv file? Since the table is not a real question it does not appear in the csv file. Maybe I would have to assign numbers to each attribute but I am also unsure on how to do that.

I would really appreciate your help! Thank you and cheers!

Franzi
Hi Franzi,



You are saying you have attributes in two columns and you have to randomly present these. Did you mean that.



Also say first row in table column 1 have value Good and columnn2 have value Ok so do you want respondent to show Good and ok as option to select.
Thank you for your message. That is not what I meant, sorry if it was unclear. What I mean is the following:

I have two columns and yes, e.g., in one column (let's call it "program 1") I have "good" and in the other ("program 2") "ok". Another attribute would be "bad" and they show up randomly for the respondent. Let's say the respondent decides that she wants "good" and selects "program 1". In my csv file I will only see that the respondent chose "program 1" but it does not tell me what program 1 was neither which attributes the respondent saw. She could have seen "bad" and "ok", or "bad" and "good" etc. And I am wondering if there is a way to program that this information is shown in the csv file?

I hope it is clearer now, thank you very much for your support!
Create embedded variables program1 and program2 in your survey flow. The in your JS that picks random values, update the value of the embedded values:

```

Qualtrics.SurveyEngine.setEmbeddedData("program1", randVal1);

Qualtrics.SurveyEngine.setEmbeddedData("program2", randVal2);

```

You will then have columns in your csv labeled program1 and program2 with the values for each respondent.
Thank you, Tom. Another question: I do not have to set a value in the embedded data variables for program1 and program2? And in total I have 4 rows, so it is not just one attribute which would then appear in the csv but several attributes. Does this change anything for the JS that you've kindly provided?
And, one more thing, this table is shown several times in a row and everytime I would need to know in csv what the respondents have seen. Do I then have to create several embedded data variables or is one enough that goes after all the blocks that have the table in them?
> @fdeeg said:

> Thank you, Tom. Another question: I do not have to set a value in the embedded data variables for program1 and program2?

When you create them in the survey flow? No, since you will be updating the values in your JS anyway.



>And in total I have 4 rows, so it is not just one attribute which would then appear in the csv but several attributes. Does this change anything for the JS that you've kindly provided?

You need a variable for each attribute. It sounds like your table has 4 rows and 2 columns (not including labels), so that would be 8 variables. That means you would have 8 setEmbeddedData lines in your JS.



>And, one more thing, this table is shown several times in a row and everytime I would need to know in csv what the respondents have seen. Do I then have to create several embedded data variables or is one enough that goes after all the blocks that have the table in them?

If you are randomizing the table each time it is seen (each table is different), then you would need separate embedded variables for each table.

Leave a Reply