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.
How to use Javascript to hide a multiple choice option if it matches an embedded data entry
Best answer by FranciscoL
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();
});
Sign up
Already have an account? Login
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login to the Community
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join.
No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Login with Qualtrics
Welcome! To join the Qualtrics Experience Community, log in with your existing Qualtrics credentials below.
Confirm your username, share a bit about yourself, Once your account has been approved by our admins then you're ready to explore and connect .
Free trial account? No problem. Log in with your trial credentials to join. No free trial account? No problem! Register here
Already a member? Hi and welcome back! We're glad you're here 🙂
You will see the Qualtrics login page briefly before being taken to the Experience Community
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
