What I do in an early question is ask a respondent, "How many Contracts would you like to tell me about?" and they select a number from a drop down menu. Then the following questions are for Contract 1, Contract 2, etc.. and I simply display the additional information using the Question Display logic that if Q1 =1, then show Contract 1. If Q1=2, then show Contract 1 and 2.
This may or may not work for you. But I thought I'd share!
Qualtrics.SurveyEngine.addOnReady(function()
{
var that=this.questionId;
jQuery("#"+this.questionId+" tr.ChoiceRow:not(:lt(3))").hide();
jQuery("<input type='button' id='add' value='Add Client' name='+' />").insertAfter("#"+this.questionId+" tr.ChoiceRow:last");
jQuery("#add").on('click',function(){
var c= jQuery("tr.ChoiceRow:visible").length;
jQuery("#"+that+" tr.ChoiceRow:eq("+c+")").show();
});
});
!
I thinks thread is old, but is there any way to do this on a side by side table? I need to have open text answers as well as pick lists?
@uhrxx005 wondering if I could tweak this to add another button right next to the 'add' button so respondents can remove extra fields as well?
rrauser sorry but I know very little about programming. I found this code elsewhere on the community.
Hi there - this was very helpful and worked like a charm in our survey. However, we have several of these types of questions, and when we copy the JavaScript into the new question, it seems to maintain the "counter" from the previous question, so won't allow a user to add more items if they reached the max on the earlier question. I'm not a JavaScript program, so I'm having trouble debugging where we might be able to reset the counter. I tried renaming some of the variables (e.g., "that", "c") but to no avail. Any help would be appreciated!
Hmm... making sure the new "add response fields" question is on it's own page seems to do the trick. We had multiple page breaks between the two questions, but it seems, maybe because we carried items over from the first one to a later question, that putting the new counter on its own page worked. I'm not entirely sure why this is true, so would appreciate any feedback regardless!
I've solved it for form field so it looks like this:
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 that=this.questionId;
jQuery("#"+this.questionId+" tr:not(:lt(1))").hide();
jQuery("").insertAfter("#"+this.questionId+" tr:last");
jQuery("#add").on('click',function(){
var c= jQuery("tr:visible").length;
jQuery("#"+that+" tr:eq("+c+")").show();
});
});
This was helpful. I used the code for form field byel_ . However, when I preview the individual question in the surveybuilder, the add button works well. But when I preview the entire survey, the add button does nothing.
???? please advise.
https://community.qualtrics.com/XMcommunity/discussion/comment/44326#Comment_44326Could you provide a screenshot of the question when it works and when it won't work?
Hello el_ So the "click button to add more" button works by adding more answer fields only when I preview the question from the survey editor as an individual question but when I preview my entire survey from the start it doesnt work when I get to that question, it does nothing. So I do not know if it will work in my published survey or not?
hm okay I do not have these issues. Did you change the code in any way? Maybe you could provide it to us. On that page, is this question alone or are there several questions on one page?
here is the code.
I just added a page break between the questions, it works now but it adds more buttons after 5, it adds 8,9, and 10
I didn't change the code. I have now separated the questions with page breaks.
It works now but after the 5 visible answer fields, when you click button it adds no. 8, 9,10. it skips 6 and 7, I wonder why?
How many fields do you give? This can be seen here, number of fields:
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.