Setting embedded data equal to a text entry multiple choice question value

Pete_LPete_L Community Member Qubie ✭

Setting embedded data equal to a text entry multiple choice question value

Hi Qualtrics community,

I'm using OnPageSubmit to set an embedded data value equal to the value they typed into an open ended question if they did at all. But I'm not sure how to target the text input without using the direct ID. If I have to do that I will, but it's not good. Here's my example:

When did you start driving?
1: Year: _____
2: If it's easier to recall your age, you can specify that here: ______
3: I do not drive

How do I target the text input if they selected option 1 or 2?

This is what I'm imagining in my head:
If getChoiceAnswerValue == 1, then set xxx = ?????
Else If getChoiceAnswerValue ==2, then set xxx = ?????
Else set xxx = 0

I would prefer NOT to target by document.getElementById, since I'll be using this at least 16 times.

Best Answer

  • [Deleted User][Deleted User] Qubie ✭
    Accepted Answer

    Hello @Pete_L ,

    Paste the below code in the js(OnReady) of the MC question:

    var that = this.questionId;
        jQuery("#"+that+" .InputText").on('blur',function(){
            var s1 = jQuery("#"+that+" .InputText:eq(0)").val();
            var s2 = jQuery("#"+that+" .InputText:eq(1)").val();
            Qualtrics.SurveyEngine.setEmbeddedData("xxx", s1+s2);


  • PeeyushBansalPeeyushBansal IndiaCommunity Member Wizard ✭✭✭✭✭

    You can simply use piping code to punch in embed variable like below:-


  • Pete_LPete_L Community Member Qubie ✭

    The last time I tried that in the OnPageSubmit action, it didn't set any values. I thought it was because the ChoiceTextEntryValue didn't exist yet?

    I'll try it again though.

Sign In to Comment