I am trying to display a previous matrix table as a reference for another question, using javascript to make the reference table readonly. The issue I'm running into is that the reference table is set up to on display rows in which the respondent has entered a value greater than 0.
From what I can tell, it seems as though the display logic (done by rows) will interrupt the more basic readonly script (below).
qid = this.questionId;
document.getElementById('QR~' + qid + '~' + '1~1').setAttribute("readonly",true);
document.getElementById('QR~' + qid + '~' + '1~2').setAttribute("readonly",true);
document.getElementById('QR~' + qid + '~' + '1~3').setAttribute("readonly",true);
document.getElementById('QR~' + qid + '~' + '2~1').setAttribute("readonly",true);
document.getElementById('QR~' + qid + '~' + '2~2').setAttribute("readonly",true);
document.getElementById('QR~' + qid + '~' + '2~3').setAttribute("readonly",true);
I think that I need to run a for loop to avoid this problem (with display logic among the rows). Unfortunately my I am not able to get the readonly functionality to work. Below is the for loop code I'm currently working with:
var qid = this.questionId;
var p = $(qid);
var min = 1
for(var i = min; i < 8; i++) {
p.document.getElementById('label[for="QR~' + qid + '~' + i + '~1"]').setAttribute("readonly",true);
p.document.getElementById('label[for="QR~' + qid + '~' + i + '~2"]').setAttribute("readonly",true);
p.document.getElementById('label[for="QR~' + qid + '~' + i + '~3"]').setAttribute("readonly",true);
}
Does anyone have any suggestions on how I can implement javascript to work around the display logic conflict?
Matrix Table: readonly javascript conflict with display logic
Best answer by mpf2018
I ended up figuring out a workaround for the display logic and figured I'd share the code here. I set variables for the row and column number and then added in a line to make sure that the row had to be displayed first before executing the readonly language.
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.
