Hide choice display in an in-page display question | XM Community
Question

Hide choice display in an in-page display question

  • 13 January 2020
  • 7 replies
  • 17 views

Userlevel 1
Badge +3
Hi,
I have a multiple choice question that used in-page display logic. I want to hide a choice in that question based on previous answer. However, for in-page display question, choice display can not be used. Can I use javascript for this?
Thank you very much
Huong

7 replies

Userlevel 7
Badge +22
Yes, you can use JS for this. Based on the previous answer event, toggle the choice of this question
Userlevel 1
Badge +3
@ rondev,
Can you help review my code, it doesn't work. Thank you so much.
Huong

var condition_recode = "${q://QID366/SelectedChoicesRecode}";


if (condition_recode == '6'){
jQuery("#"+this.questionId+" .Selection").eq(2).hide();
Userlevel 1
Badge +3
Hi,
I find out that this code work with question without in-page display logic. I am wondering if there is anyway in this case?
Thank you.
Huong
var condition_recode = "${q://QID366/SelectedChoicesRecode}";

if (condition_recode == '6'){
jQuery("#"+this.questionId+" li.Selection").eq(2).hide();
Userlevel 7
Badge +27
> @huongngo said:
> Hi,
> I find out that this code work with question without in-page display logic. I am wondering if there is anyway in this case?
> Thank you.
> Huong
> var condition_recode = "${q://QID366/SelectedChoicesRecode}";
>
> if (condition_recode == '6'){
> jQuery("#"+this.questionId+" li.Selection").eq(2).hide();

To do it on the same page, you can't use a piped value. As @rondev said, you need to use a JS event handler.
Userlevel 1
Badge +3
> @TomG said:
> > @huongngo said:
> > Hi,
> > I find out that this code work with question without in-page display logic. I am wondering if there is anyway in this case?
> > Thank you.
> > Huong
> > var condition_recode = "${q://QID366/SelectedChoicesRecode}";
> >
> > if (condition_recode == '6'){
> > jQuery("#"+this.questionId+" li.Selection").eq(2).hide();
>
> To do it on the same page, you can't use a piped value. As @rondev said, you need to use a JS event handler.

Hi Tom G,
Thank you for your comment. I think it's not because of the piped text because I piped the text from previous question. Then, I found that it works in the question with in-page display logic when I change the view from horizontal to vertical. I don't know why.
Thank you for your help.
Huong
Userlevel 7
Badge +27
> @huongngo said:
> Hi Tom G,
> Thank you for your comment. I think it's not because of the piped text because I piped the text from previous question. Then, I found that it works in the question with in-page display logic when I change the view from horizontal to vertical. I don't know why.
> Thank you for your help.
> Huong
That's because a horizontal MC uses a table instead of an unordered list. So, "li.Selection" isn't valid for a horizontal MC.
Userlevel 1
Badge +3
> @TomG said:
> > @huongngo said:
> > Hi Tom G,
> > Thank you for your comment. I think it's not because of the piped text because I piped the text from previous question. Then, I found that it works in the question with in-page display logic when I change the view from horizontal to vertical. I don't know why.
> > Thank you for your help.
> > Huong
> That's because a horizontal MC uses a table instead of an unordered list. So, "li.Selection" isn't valid for a horizontal MC.
>

Hi Tom G,
Could you help with this? I know very little about javascript.
Thank you and best regards,
Huong

Leave a Reply