Hello,
I am building a simple survey to collect questions for an FAQ. I have two questions - Q1. Submit questions from a team member’s perspective and Q2. Submit questions related to a manager's perspective.
I am using the form field type so responders can input multiple questions and have each question in a separate field.
Utilizing the JavaScript below, copied to both questions, I am able to add a button that allows a responder to add additional fields to submit additional questions. However, I’d like the code to function independently for each question. Right now, during preview, if I click ‘add field’ under question 1 it also adds a field under question 2 and the ‘add field’ under question 2 doesn’t work. It works perfect if I do a page break, but I’d like the questions to be on the same page. Any help would be wonderful!
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
jQuery("#"+this.questionId+" td:not(.ControlContainer)").hide();
});
Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
var cs = jQuery("#"+this.questionId+" .ChoiceStructure");
cs.find("tr:not(:lt(1))").hide();
cs.append("<input type='button' id='add' value='Add Question' name='+' />");
jQuery("#add").on('click',function(){
var c = cs.find("tr:visible").length;
cs.find("tr:eq("+c+")").show();
});
});
Qualtrics.SurveyEngine.addOnUnload(function()
{
/*Place your JavaScript here to run when the page is unloaded*/
});