Hello,
I have a survey where I want members of a team to evaluate their peers. When they are in the survey, there is a multiple choice question with 100 names, where they can choose the name of the colleague they will be evaluating.
I would like to write a javascript code which hides certain names, if they match entries in the embedded data of the survey. For example, I would like to hide the name of the person who is filling the survey, and also names that such person has already evaluated (these names are stored in the embedded data). I know this can be achieved with display logic for each individual option, but I would have to insert 10 conditions for each of the 100 options.
I tried doing this, based on other topics of this forum without success, I believe this may be a simple syntax error, but I'm not experienced in Javascript so I cannot understand the issue... Can anybody help me understand the issue, please?
My goal with this code would be to get the id of the option corresponding to the name, and then hiding that id, but it does not work:
var a = getChoicesFromVariableName("${e://Field/Name}");
var id=a[0];
jQuery("#"+this.questionId+" input[choiceid=" + id + "]").closest("li").hide();
I appreciate your attention and insights.
Best Regards,
Francisco.
Page 1 / 1
I don't think you need javascript for this. You can click on an answer option and set display logic to display if Embedded data variable X Does not equal Y.
Yes, I could do it as you mentioned, as I wrote in the original post. The issue was that I had 100 options, and they can change monthly, so it would make sense to automate it through Javascript.
I found a suitable way, suggested by TomG , and I'll leave it here if anybody has the same issue:
jQuery("#"+this.questionId+" label.SingleAnswer").each(function() {
var label = jQuery(this);
if(label.text() == "${e://Field/Name}") label.closest("li").hide();
});
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.