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

Hide question based on embedded data using javascript

  • Sep 7, 2020 12:13 PM UTC
  • 9 replies
  • 170 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")

}

View original

9 replies

rondev
Level 6 ●●●●●●
Forum|alt.badge.img+22
  • Level 6 ●●●●●●
  • Sep 7, 2020 12:42 PM UTC

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 ●●
  • Sep 7, 2020 1:09 PM UTC

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
  • Sep 7, 2020 2:23 PM UTC

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 ●●
  • Sep 7, 2020 2:48 PM UTC

Thank you Rondev


Forum|alt.badge.img+3
  • Author
  • Level 2 ●●
  • Sep 7, 2020 3:00 PM UTC

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 ●●●●●●
  • Sep 7, 2020 3:06 PM UTC

Forum|alt.badge.img+3
  • Author
  • Level 2 ●●
  • Sep 7, 2020 3:32 PM UTC

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


rondev
Level 6 ●●●●●●
Forum|alt.badge.img+22
  • Level 6 ●●●●●●
  • Sep 7, 2020 3:36 PM UTC

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 ●●
  • Sep 8, 2020 8:30 AM UTC

Thanks rondev