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?
Page 1 / 1
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.
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.