Dynamically changing text in a text question depending on the choices in a previous hot spot question | XM Community
Skip to main content
Question

Dynamically changing text in a text question depending on the choices in a previous hot spot question

  • August 23, 2023
  • 1 reply
  • 188 views

Forum|alt.badge.img

Hi!
I need. help in setting logics in one of my surveys.

I am trying to write a Java Script code that. would enable me to dynamically change text in a text question depending on the choices in a previous hot spot question. Could anyone help me how such a code would look like?

1 reply

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • 6084 replies
  • August 23, 2023

Put the text you want to change inside a html element with a class:

<span class="changeThis">text to change dynamically</span>

Then dynamically change it with JS:

var changeThis = jQuery("#"+this.questionId+" .changeThis");
if("{piped text}"=="x") changeThis.html("new text if x")
else if("{piped text}"=="y") changeThis.html("new text if y");