Hide an open-text option when other options are carried-forward across 2 items | XM Community
Solved

Hide an open-text option when other options are carried-forward across 2 items

  • 22 July 2020
  • 2 replies
  • 14 views

Badge +1

Hi!
Here are my items:
Q1: Please select all options that apply.
A
B
C
D
Other (please specify) [open text line]

Only those selected among A,B,C,D are carried to Q2. I can get the "Other" option to be hidden for this Q2, using jQuery("#"+this.questionId+" li.Selection").eq(4).hide();
Q2: Please select your TOP choice .
A
B
C
D
Those that were NOT selected in Q2 are to be carried to Q3. However, this means that the "Other" option gets carried-over, as well (because it was only hidden).
Q3: Please select your BOTTOM choice. (Suppose that A gets selected)
B
C
D
Other (please specify)

Thus, I don't want to hide an element based on a selected element number, as that element number appears to change as a result of the choice selected.
Is there a way to select an element based on the 'label' of the option?
pseudo-logic., jQuery("#"+this.questionId+" li.Selection").[ select element with label, "Other (please specify)"].hide();

Otherwise, how can I carry forward an original list, while hiding the Other option?

Thanks in advance!



icon

Best answer by SurajK 22 July 2020, 20:35

View original

2 replies

Userlevel 5
Badge +4

Hi yk_mr ,
You can simply remove the last element on Q2 and Q3 using one line of code,
jQuery('#'+this.questionId+' ul li').last().remove();
Because any how the other option will be in last position.

Badge +1

Perfect, thank you, SurajK, for the sweet and simple solution! I'm a complete newbie to jQuery, so looking forward to learning on this forum.

Leave a Reply