I am trying to create a survey page in Qualtrics that has multiple form field questions. Responders may want to add up to 10 responses, but to streamline the UI, I want to initially only show one field, with the option to add a field if they need more than one field.
I have been able to make an "add field" button that works for the top question, but when I use multiple questions with the same Javascript, only the first "add Field" button works, and it adds the extra field for every question on the page. Clicking the "add field button" for subsequent questions doesn't seem to work.
Javascript code to create the "Add field button" can be seen below:
Qualtrics.SurveyEngine.addOnload(function(){
var cs = jQuery("#"+this.questionId+" .ChoiceStructure");
cs.find("tr:not(:lt(1))").hide();
cs.append("<input type='button' id='add' value='Add field' name='+' />");
jQuery("#add").on('click',function(){
var c = cs.find("tr:visible").length;
cs.find("tr:eq("+c+")").show();
});
});