Load text option for multiple choice (single and multiple answer) on click | XM Community
Skip to main content
Hello guys!

I have the following code to load the text box for multiple choices on click, for the vertical options of multiple and single answer choices:



jQuery("#" + QID + " .InputText ").hide();

jQuery("#" + QID + " input[type='radio']").each(function(){



if(jQuery(this).prop("checked") == true)

{

var v1 = jQuery(this).attr("id");

jQuery("[id*='"+v1+"~TEXT']").show();

}

else

{

var v1 = jQuery(this).attr("id");

jQuery("[id*='"+v1+"~TEXT']").val('');

jQuery("[id*='"+v1+"~TEXT']").hide();

}

});





jQuery("#" + QID + " .Selection ").on("click change",function(){



jQuery("#" + QID + " input[type='radio']").each(function(){



if(jQuery(this).prop("checked") == true)

{

var v1 = jQuery(this).attr("id");

jQuery("[id*='"+v1+"~TEXT']").show();

}

else

{

var v1 = jQuery(this).attr("id");

jQuery("[id*='"+v1+"~TEXT']").val('');

jQuery("[id*='"+v1+"~TEXT']").hide();

}

});

});



});



However, when I change the type to either vertical or column, the code doesn't work properly - text boxes only show up on clicked items after I try to move on and validation doesn't allow me.



Beyond that, I want to have the text box always appear below ALL the choices, so that it is a large text box that doesn't meddle in the space between choices.



Is there any way to do any of these?
in above code try replacing "Selection" with "ControlContainer"



So, if the alignment is "horizontal or column" then use "ControlContainer" in place of "Selection"

"Selection" used for "vertical" alignment.



Please make sure to keep the " ." (space and dot) before "Selection" as it is...so, it will be

jQuery("#" + QID + " .ControlContainer")
Thanks @Mohammedali_Rajapakar_Ugam! Do you know of any way that I could have a text box pop up below the options (in the same question) but just be one box instead of multiple that show up between choices?



Also, in terms of grouping, is there any way to keep grouping (with labels) in horizontal or column?



Thanks!
So, you want the "text-box" to appear for one specific option only? Can you create a dummy survey with that question and share the link with us?



"Grouping" option is not applicable for horizontal and column setting...
@Mohammedali_Rajapakar_Ugam I want the "text-box" to appear for every option chosen. Its a question with 8 options, all of which have text entries that pop up (through JQuery) only if the choice is clicked. However, the "text-box" appears between the selected choices. I want to have the text box appear below all the options, regardless of which option is clicked, without having to create a new question.

Leave a Reply