
Solved
Side-by-side question: constant sum and auto-complete dropdown
Hi all
Hoping someone on here can help me out (or point me in the right direction!).
There are two main things that I am trying to achieve for the same question:
1. Constant sum for a column in a side-by-side question (I found some script for a matrix table but not for side-by-side). I have managed to get % signs beside the boxes but not the constant sum element. What I want to do is add a new row at the bottom and only show the cell for column 'Percentage Time Allocation on this Process Step (%)', and have that cell be the constant sum to 100%.
2. In the same question, for the column 'Standardised Activity Tag', I would like to auto-complete the dropdown menu with an embedded data field ($e{://Field/p1ps1sat for row 1 etc.). I want to give participants a pre-filled cell and allow them to change the input based on the values in the dropdown.
I don't know any JS and am scrambling to solve the above issues! If anyone could help me out, that would be very much appreciated.
Aaron!

Best answer by Samarth
Hi @aaron ,
I am getting error while uploading the QSF file please find javav script code need to be placed in
question.
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
});
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
var $jq = jQuery.noConflict();// always keep this
$jq('input[type="text"]').after('%'); //insert % sign after boxes
$jq('.SBS1 select:last').hide(); // remove last select for Column 1
$jq('.SBS3 select:last').hide(); // remove last select for Column 3
$jq('.SBS4 select:last').hide(); // remove last select for Column 4
var $sum = 0; // define sum variable
$jq('.SBS2 input:last').val($sum); // setting the value of total box
//function for changing text value to numeric
function getVal(val){ var num = parseInt(val); if(isNaN(num)) { num = 0; } return num; };
// calculating some on change
$jq('.SBS2 input').not(':last').change(function(){
// for every box
var $sum = 0; // define sum variable
$jq('.SBS2 input').not(':last').each(function(){
$sum += +getVal($jq(this).val());
});
$jq('.SBS2 input:last').val($sum);
});
});
Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/
});
Regards,
Samarth
View originalLeave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.