Custom code for creating space in between 2 specific options in a 3 item multiple choice format | XM Community
Skip to main content

Custom code for creating space in between 2 specific options in a 3 item multiple choice format

  • November 15, 2022
  • 1 reply
  • 60 views

Forum|alt.badge.img+1

Hi!
Can anyone please provide me with a custom code in order to create space in between 2 specific options (column style) in a 3-item multiple choice format. Please find attached an example of the desired end state.
Any help would be much appreciated, thank you!
example.png

1 reply

Forum|alt.badge.img+4
  • QPN Level 1 ●
  • November 18, 2022

Qualtrics.SurveyEngine.addOnReady(function () {
  const container = this.getQuestionContainer()
  let tbody = container.querySelector(
    "div.QuestionBody table.ChoiceStructure tbody"
  )
  let rows = tbody.childElements()
  let lastrow = rows[rows.length - 1]
  let box = lastrow.querySelector("td.LabelContainer label")


  // add spacer
  const spacer = document.createElement("tr")
  tbody.insertBefore(spacer, lastrow)


  // OPTION: increase the value below to add more space
  spacer.style.height = "40px"


  // make second row button smaller
  box.style.display = "inline-block"


  // OPTION: adjust the value below to make second row button wider or more narrow
  box.style.paddingInline = "10px"
})