Text Entry Box next to Multiple Choice Answers | XM Community
Skip to main content
Question

Text Entry Box next to Multiple Choice Answers

  • May 12, 2023
  • 1 reply
  • 276 views

Forum|alt.badge.img+5
  • Level 1 ●
  • 1 reply

I have a multiple choice question and for two answer options I want to add text entry boxes.

My problem is that per default the boxes are shown beneath the answer, but I want them right next to the answer. If I only have one answer option with text entry (e.g. “other: _______”, I use the following Java Code that works perfect:

Qualtrics.SurveyEngine.addOnload(function()
{
    /*Place your JavaScript here to run when the page loads*/

});

Qualtrics.SurveyEngine.addOnReady(function()
{
    var QID = this.questionId;
var QIDOtherLabel = jQuery("#" + QID).find(".TextEntryBox").siblings().attr("id");
jQuery("[id='" +QIDOtherLabel+"']").append(jQuery("#" + QID).find(".TextEntryBox"));
jQuery("[id='" +QIDOtherLabel+"']").css("padding-top","30px");
jQuery("[id='" +QIDOtherLabel+"']").css("padding-bottom","30px");
jQuery("#" + QID).find(".TextEntryBox").css("float","unset");

});

Qualtrics.SurveyEngine.addOnUnload(function()
{
    /*Place your JavaScript here to run when the page is unloaded*/

});

But if I have two answer options with text entry boxes, it moves both boxes to the first answer options (no box instead at “other:”):

How can I modify the Java Code so that both boxes are shown correctly right to both answer options?

THANKS FOR ANY SUPPORT!

1 reply

Shashi
Level 8 ●●●●●●●●
Forum|alt.badge.img+32
  • Level 8 ●●●●●●●●
  • 633 replies
  • May 12, 2023

Use below code:

	var QID = this.questionId;
	jQuery("#"+this.questionId+" .InputText").each(function(){
		var QIDOtherLabel = jQuery("#" + QID).find(this).siblings().attr("id");
		jQuery("[id='" +QIDOtherLabel+"']").append(jQuery("#" + QID).find(this));
		jQuery("[id='" +QIDOtherLabel+"']").css("padding-top","30px");
		jQuery("[id='" +QIDOtherLabel+"']").css("padding-bottom","30px");

	});
	jQuery("#" + QID).find(".TextEntryBox").css("float","unset");

 


Leave a Reply