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.

retrieve matrix table selected values using javascript?

makgul
makgul Community Member Qubie ✭

Hello everyone,

I want to make a custom calculation on the values of a matrix table of 10 rows. To do so I was trying to retrieve the individual values of each row using

var r1ar = parseInt("${q://QID81/SelectedAnswerRecode/1}");

var r2ar = parseInt("${q://QID81/SelectedAnswerRecode/2}");

var r3ar = parseInt("${q://QID81/SelectedAnswerRecode/3}");

...

statements. The above code is not working. I used the alert statement to retrieve the selection value

alert("${q://QID81/SelectedAnswerRecode/1}")

and got an empty alert window.

I have added the code on Qualtrics.SurveyEngine.addOnPageSubmit function. Can you please guide me how I can reach the individual values of a matrix table?

Thank you,

Answers

  • ahmedA
    ahmedA IndiaCommunity Member, XMPN Member Wizard ✭✭✭✭✭

    You need to have a page break between storing values and using the Qualtrics Piped text format.

  • makgul
    makgul Community Member Qubie ✭

    Thank you ahmedA! it worked. Is there any other way without adding any page break? If it needs additional javascript (adding an event to the matrix table) I am also fine with that one.

    Thank you!

  • ahmedA
    ahmedA IndiaCommunity Member, XMPN Member Wizard ✭✭✭✭✭

    You can add an event listener to next button and pull the values from the matrix.

  • makgul
    makgul Community Member Qubie ✭

    thanks ahmedA!

    On the same question without adding any page breaks, I have added the following code within the Qualtrics.SurveyEngine.addOnReady and Qualtrics.SurveyEngine.addOnPageSubmit functions

    $('NextButton').onclick = function (event) {

    alert("${q://QID81/SelectedAnswerRecode/1}")

    alert("${q://QID81/SelectedAnswerRecode/2}")

    };

    and got an empty alert window. Can you please suggest if my code is correct and provide a direction? Thank you!

  • ahmedA
    ahmedA IndiaCommunity Member, XMPN Member Wizard ✭✭✭✭✭

    "${q://QID81/SelectedAnswerRecode/1}" These values come from the server. Hence will ONLY be available in the next page.

    Pick the value from the matrix itself, the input box or whatever you have.

    Read up on the Qualtrics JavaScript API, this will give you an idea of what all information you can gather.

    If you're facing issues in a particular case, share the preview link, along with what you are looking for and maybe I'll be able to provide more directed help.

  • makgul
    makgul Community Member Qubie ✭

    thanks ahmedA,

    I can retrieve the values from input boxes, multiple choice or forms on the page. However, for the matrix table I don't know how to retrieve the values without asking the server. I have searched on the the internet and couldn't find it. If you can share a resource that enables me to get the values of a matrix table on the page using jquery or any other form of javascript that would be great!

    There is nothing special: on the page I need to retrieve the selected values from the matrix table to calculate an embedded field.

    Thank you for your help.

  • ahmedA
    ahmedA IndiaCommunity Member, XMPN Member Wizard ✭✭✭✭✭

    If you're facing issues in a particular case, share the preview link, along with what you are looking for and maybe I'll be able to provide more directed help.

  • makgul
    makgul Community Member Qubie ✭

    thank you ahmedA. since this is a university project I need to get approval from the committees before sharing anything even if it is a preview. thank you for your help.

  • ahmedA
    ahmedA IndiaCommunity Member, XMPN Member Wizard ✭✭✭✭✭

    Okay. Take your time. However, generally for confidential things, people just put dummy text and share it. But it's your call.