I have done something similar, but with a Slider question. Here is the code: Qualtrics.SurveyEngine.addOnload(function() { /*Place your JavaScript here to run when the page loads*/ var result=0; this.questionclick = function(event,element){ result = this.getChoiceValue(1); document.getElementById("result").innerHTML= result; } }); Then in the HTML View of the question, type the following: The value is currently: <span id="result">0</span>
I've managed a very inelegant way to get my Total over all rows and columns using addOnPageSubmit. But still, I can't use my total in my onClick part (previous comment), as I only managed to calculate my total on another section of code (addOnPageSubmit). Here is the extra chunck of code. Please help me improve this very yucky code!! Qualtrics.SurveyEngine.addOnPageSubmit(function() { /*Place your JavaScript here to run when the page is submitted */ var qid = this.questionId; var totalRow = 0; for ( rowNum = 1; rowNum <= 5; rowNum++){ for ( colNum = 1; colNum <= 3; colNum++){ var resp = Qualtrics.SurveyEngine.registry[qid].getChoiceValue(rowNum, colNum); // boolean: 1 if selected, false otherwise. if (resp == true){ resp = colNum; }else{ resp = 0; } totalRow = totalRow + resp; } } Qualtrics.SurveyEngine.setEmbeddedData( 'totalRow', totalRow);
I think I found a way of doing what you are looking for, but I did it by mistake trying to solve my own problem. Check out my discussion, I shared the code I am currently using (and which is not doing what I want, but what I understand you want!!) qualtrics.com/community/discussion/2529/matrix-profile-question-count-number-of-selected-cells-per-column#latest
So far, I've been able to save as embedded data the selection value for each row, upon clicking on a cell of a given row. Now the main issue is to save the grand total. Currently, what my code relative to the grand total is doing is the following: every time I click on a cell, it concatenates the column number of the selected cell to the current value of the grand total ("totalRow"). For example, if I click on this sequence: - row 1, column 1, - row 2, column 3 - row 3, column 1 - row 4, column 2 - row 5, column 1, - then re-click on row 5, now column 3, what is saved as embedded data field "totalRow" is: "131213". Does anybody know how to save instead the actual sum of the final selections, i.e. 10 ? Thanks in advance! Here's my current code: Qualtrics.SurveyEngine.addOnReady(function() { /*Place your JavaScript here to run when the page is fully displayed*/ var qid = this.questionId; var totalRow = 0; this.questionclick = functio
Already have an account? Login
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.
Sorry, we're still checking this file's contents to make sure it's safe to download. Please try again in a few minutes.
Sorry, our virus scanner detected that this file isn't safe to download.