Hi,
does anyone from the community, know how to make the rank order question in the text box format, automatically rank when the user clicks on the text box?
This code bellow in js, I used it for many years, and now I don't know why, it stopped working
Thank you very much
Qualtrics.SurveyEngine.addOnload(function()
{
var maxRank = 3;
var currentRank = 1;
$$('#'+this.questionId+' .QuestionBody input').each(function(el) {$(el).observe('click', function(event) {
if(currentRank > maxRank)
currentRank = xx ;
event.toElement.value = currentRank++;
})});
var questionID = this.questionId;
$('resetButton').observe('click', function(event) {currentRank = 1; console.log($$('#'+questionID+' .QuestionBody input'));$$('#'+questionID+' .QuestionBody input').each(function(el) {el.value = ""});});
});
rank order text box
Best answer by JeremyK
Alright, just figured it out!
I created a resetButton in my question HTML and tested the textbox reset as well. The only thing I don't like about my solution is I couldn't figure out how to select the elements using the QuestionId, so I omitted it, but that could cause problems in the future (or maybe now) since the jQuery runs against the entire page. Let me know if you have problems with it, thanks!
Here's my take on a solution:
Qualtrics.SurveyEngine.addOnload(function () {
var maxRank = 4;
var currentRank = 1;
jQuery('.ChoiceStructure').children().on("click", function () {
if (currentRank <= maxRank) {
jQuery(this).children("input[type='text']:first").val(currentRank);
currentRank = ++currentRank;
};
});
jQuery('#resetButton').on("click", function () {
jQuery(".ChoiceStructure[role='list']").children().children("input[type='text']").val("");
currentRank = 1;
});
});
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.
