Hide question based on embedded data using javascript | XM Community
Skip to main content
Solved

Hide question based on embedded data using javascript

  • September 7, 2020
  • 9 replies
  • 107 views

Forum|alt.badge.img+3

Hi,
I was wondering whether it is possible to hide a column in a side by side question based on an embedded data value.
Question.PNGI would like to hide the second column if the embedded data field "additional question" meets the set the value of '1'.
Thanks
Mark

Best answer by rondev

https://www.qualtrics.com/community/discussion/comment/30027#Comment_30027Similar to below (Replace ED1 with your embedded data name):
if("${e://Field/ED1}"=="1"){
jQuery("#"+this.questionId+" .SBS2").css("visibility","collapse")

}

9 replies

rondev
Level 6 ●●●●●●
Forum|alt.badge.img+22
  • Level 6 ●●●●●●
  • September 7, 2020

Apply if condition on embedded data and use below code in to hide second column:
jQuery("#"+this.questionId+" .SBS2").css("visibility","collapse")


Forum|alt.badge.img+3
  • Author
  • Level 2 ●●
  • September 7, 2020

Thanks Rondev. I'm quite new JS, are you able to provide a bit more of what the code would look like? Eg do i need to add var for the embedded data field?


rondev
Level 6 ●●●●●●
Forum|alt.badge.img+22
  • Level 6 ●●●●●●
  • Answer
  • September 7, 2020

https://www.qualtrics.com/community/discussion/comment/30027#Comment_30027Similar to below (Replace ED1 with your embedded data name):
if("${e://Field/ED1}"=="1"){
jQuery("#"+this.questionId+" .SBS2").css("visibility","collapse")

}


Forum|alt.badge.img+3
  • Author
  • Level 2 ●●
  • September 7, 2020

Thank you Rondev


Forum|alt.badge.img+3
  • Author
  • Level 2 ●●
  • September 7, 2020

What would the class name be for a text entry question? I'm trying to do the same for a text entry question and hide the first row but i assume SBS2 can only be used side-by-side?
would it be
if("${e://Field/ED1}"=="1"){
jQuery("#"+this.questionId+" .TE1").css("visibility","collapse")


rondev
Level 6 ●●●●●●
Forum|alt.badge.img+22
  • Level 6 ●●●●●●
  • September 7, 2020

Forum|alt.badge.img+3
  • Author
  • Level 2 ●●
  • September 7, 2020

Yes, text entry of type form - with two fields.


rondev
Level 6 ●●●●●●
Forum|alt.badge.img+22
  • Level 6 ●●●●●●
  • September 7, 2020

https://www.qualtrics.com/community/discussion/comment/30037#Comment_30037For this we do not need JS, you can directly add display logic using answer choice display logic


Forum|alt.badge.img+3
  • Author
  • Level 2 ●●
  • September 8, 2020

Thanks rondev