Community Groups are officially here!
We've released Groups, a new feature that enables us to connect community members of similar industries and interests in a shared, private space. You can check out all of the details here, including information about who can join, how to join, and what Groups are currently offered. Please leave your feedback through this Community Groups Feedback Survey.

How to add static text after a text entry box?

2»

Answers

  • Sherly
    Sherly London Qubie ✭

    Hi Tom,
    I did what you said:

    Qualtrics.SurveyEngine.addOnload(function() {
    var input = jQuery("#"+this.questionId+" .InputText");
    input.after(" ${q://QID490/ChoiceDescription/1}");
    input.css("width","120px");
    });

    When I preview the question, it did not show the static text in main language "tahun" (I believe this because I delete this: "input.after(" tahun");" as you suggested. When I look at the translated version "years" also did not show off.

    Thank you,

  • Sherly
    Sherly London Qubie ✭

    I would like "tahun" shows in the main language (Indonesia) and "years" in my translated version (English). Is it possible to do that? Thank you.

  • TomG
    TomG Raleigh, NC Wizard ✭✭✭✭✭
    edited November 2018

    @Sherly,

    Two things:
    1. Q490 (the question label) and QID490 (the internal question id) are NOT the same thing. You need to use the correct QID. Pipe it into the question text of your question, then cut and paste it into your JavaScript.
    2. You can't use Preview Question to check piped values, the values don't resolve. You need to use Preview Survey.

  • Sherly
    Sherly London Qubie ✭

    @TomG

    Sorry if I ask again, I still didn't get it.
    As you suggested,
    1. I created new questions with translation (English)
    2. I managed to do display logic with hide=1
    3. I put this into my javascript:
    Qualtrics.SurveyEngine.addOnload(function() {
    var input = jQuery("#"+this.questionId+" .InputText");
    input.after(" ${q://QID490/ChoiceTextEntryValue/1}");
    input.css("width","120px");
    });

    "${q://QID490/ChoiceTextEntryValue" This is my pipe text of question label Q490.
    Should I pipe to the new translated question(English) or to the original question (Indonesia)?

    1. I am sorry, I mean I used Preview Survey. It still did not work for translation and for the original.

    What did I miss now?
    Thank you so much

  • TomG
    TomG Raleigh, NC Wizard ✭✭✭✭✭

    I'm fairly certain that the pipe of the first choice in Q490 is NOT ${q://QID490/ChoiceTextEntryValue/1}. As I said in my last message, using "Piped text..." select the Q490 choice description into your question text. That will give the you the correct pipe string (with a QID that is not QID490). Then cut and paste it from your Question Text into your JS.

    I don't understand your "Should I pipe to the new translated question(English) or to the original question (Indonesia)?" question. You can't choose which language to pipe. Qualtrics pipes the current language.

  • Sherly
    Sherly London Qubie ✭

    Hi @TomG
    This is how I do the pipe text.

    The result that I got is ${q://QID490/ChoiceTextEntryValue}
    Am I doing it wrong?

    I don't understand your "Should I pipe to the new translated question(English) or to the original question (Indonesia)?" question. You can't choose which language to pipe. Qualtrics pipes the current language.
    What I mean for that question is, when I want to choose questions to pipe, should I choose my original question or should I choose new question that I just created (English).

    Also, as I said, when I do think, my original question did not contain static year anymore.
    Thank you.

  • CarolK
    CarolK Guru ✭✭

    I am using this approach and it works perfectly when (a) I only have one text prompt or (b) all the prompts on a grid should have the same label. I am wondering if there is a tweak I need to use so that I could use two different labels (where one label should be "days" and another should be "%" for example)?

    @Clint said:
    With the addition of some JavaScript on the question, you can get this done.

    This example shows how to put text on either side of the text entry box.
    https://gist.github.com/13bzhang/92be517b6558132c78620ad029c77f4d

    Qualtrics.SurveyEngine.addOnload(function()
    {
      /*Place Your Javascript Below This Line*/
      
    var inputs = $(this.getQuestionContainer()).select('input[type="text"]');
    
    for (var i = 0; i < inputs.length; i++) {
      var input = inputs[i];
      $(input).insert({before: 'In '});
      $(input).insert({after: ' years'});
    }
    
    
    });