HTML codes for Conjoint Experiment | XM Community
Skip to main content

Dear dedicated Qualtrics users

 

I am a doctoral student who is preparing to construct conjoint experiment in Qualtrics. Since my university does not have Qualtrics DesignXM where conjoint module is supported but only have a plain, regular version of Qualtrics, I decided to construct it outside the Qualtrics space and import it in Qualtrics.

 

Following Weber’s(2021)  method (A step-by-step procedure to implement discrete choice experiments in Qualtrics. Social Science Computer Review, 39(5)), I created “advanced format TXT file” using Stata and import the TXT file in Qualtrics. 

However, below is what I got from my HTML code that I wrote in the TXT file.

 

 

Obviously, I need 4 more cells under the Option 3 column, and I just cannot figure out what I did wrong with my HTML code. Below is the HTML code that I wrote in Stata to construct tables, and can someone please let me know the correct HTML code that I need to use to make the cells appear under the Option 3 column by any chance?

Your help would be deeply appreciated. 

 

*** 3. Build HTML tables and include them in a Qualtrics' advanced format TXT file ***

*Definition of parameters for HTML tables
*Reference for HTML colors: https://www.w3schools.com/colors/colors_picker.asp
local rulecolor #1524D9 // (= bright blue) color of the table's rules
local cellcolor #BEDCFC // (= light blue) background color of the table's cells
local firstheadcolstyle style="width:180px; border-bottom: 1px solid `rulecolor';"
local headcolstyle bgcolor="`cellcolor'" style="width:270px; text-align: center; border-left: 4px solid `rulecolor'; border-top: 4px solid `rulecolor'; border-right: 4px solid `rulecolor'; border-bottom: 1px solid `rulecolor';"
local headrowstyle height="100" style="text-align: left; border-bottom: 1px solid `rulecolor';"
local rowstyle bgcolor="`cellcolor'" style="text-align: center; border-left: 4px solid `rulecolor'; border-right: 4px solid `rulecolor'; border-bottom: 1px solid `rulecolor';"
local lastrowstyle bgcolor="`cellcolor'" style="text-align: center; border-left: 4px solid `rulecolor'; border-right: 4px solid `rulecolor'; border-bottom: 4px solid `rulecolor';"

*Initialize txt document
texdoc init DCE_SR2_${lg}.txt, replace
tex laAdvancedFormat]]

forv n = 1/`=_N' { // = foreach line in the dataset
    *Store the values in locals
    local B = block`n']
    local C = choicetask `n']
    forv i = 1/3 {
        forv j = 1/4 {
            local header_`j': variable label A1_`j'
            local A`i'_`j' = A`i'_`j'r`n']
        }
    }

    *Include a Qualtrics' block separator 
    *(if the block is different from previous one)
    if block`n']!=blockl`=`n'-1'] {
        tex s Block:CE_Block`B']]
    }

    *Include a Qualtrics' question separator and a question label
    tex Question:Matrix]]
    tex ioID:CE_ChoiceTask`C']]
    
    *Question to be asked to the respondent
    if "$lg"=="EN" {
        tex Among the following job options, which one do you prefer? </br >
    }
    if "$lg"=="FR" {
        tex Parmi les options de voyage suivantes, laquelle préférez-vous? </br >
    }
    
    *Beginning of HTML table for displaying the choice task
    tex <br />
    tex <style type="text/css">table {
    tex border: none;
    tex border-collapse: collapse;
    tex }
    tex th, td {
    tex padding: 5px;
    tex }
    tex th {
    tex text-align: left;
    tex }
    tex td:first-child {
    tex border-left: none;
    tex border-top: none;
    tex }
    tex </style>
    tex <table>
    tex <tbody>
    
    *Column headers
    tex <tr>
    tex <td `firstheadcolstyle'> </td>
    tex <td `headcolstyle'><strong>Option 1</strong></td>
    tex <td `headcolstyle'><strong>Option 2</strong></td>
    tex <td `headcolstyle'><strong>Option 3</strong></td>
    tex </tr>
    
    *Attribute 1 to 3 (all but the last)
    forv j = 1/3 {
        tex <tr>
        tex <td `headrowstyle'><strong>`header_`j''</strong></td>
        tex <td `rowstyle'>`A1_`j''</td>
        tex <td `rowstyle'>`A2_`j''</td>
        tex </tr>
    }
    *Attribute 4 (bottom rule is different for the last attribute)
    tex <tr>
    tex <td `headrowstyle'><strong>`header_4'</strong></td>
    tex <td `lastrowstyle'>`A1_4'</td>
    tex <td `lastrowstyle'>`A2_4'</td>
    tex </tr>

    tex </tbody>
    tex </table>

Be the first to reply!

Leave a Reply